You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/07/09 03:44:12 UTC

[GitHub] [superset] liuyong888 opened a new issue #15613: How do I get current datetime in the SQLTemplate?

liuyong888 opened a new issue #15613:
URL: https://github.com/apache/superset/issues/15613


   **Is your feature request related to a problem? Please describe.**
   I want to get current datetime in SQL Template
   
   **Additional context**
   That seems like the wrong way to go.
   It says datetime is Undefined.
   ![image](https://user-images.githubusercontent.com/45752479/125019981-90015280-e0aa-11eb-9303-6ffca38347ec.png)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] junlincc closed issue #15613: How do I get current datetime in the SQLTemplate?

Posted by GitBox <gi...@apache.org>.
junlincc closed issue #15613:
URL: https://github.com/apache/superset/issues/15613


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie edited a comment on issue #15613: How do I get current datetime in the SQLTemplate?

Posted by GitBox <gi...@apache.org>.
zhaoyongjie edited a comment on issue #15613:
URL: https://github.com/apache/superset/issues/15613#issuecomment-877742092


   we can make macros in the `config.py`, for instance:
   
   ```
   from datetime import datetime
   
   def current_datetime():
       return datetime.now().strftime("%Y-%m-%d")
   
   JINJA_CONTEXT_ADDONS = {
       "current_datetime": current_datetime
   }
   ```
   
   ensure that the flag `ENABLE_TEMPLATE_PROCESSING` is enabled
   ```
   FEATURE_FLAGS = {
       ...
       "ENABLE_TEMPLATE_PROCESSING": True,
   }
   ```
   
   Then use in SQLLab
   
   ```
   select ...
   from ...
   where start > {{ current_datetime() }}
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on issue #15613: How do I get current datetime in the SQLTemplate?

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on issue #15613:
URL: https://github.com/apache/superset/issues/15613#issuecomment-877742092


   we can make macros in the `config.py`, for instance:
   
   ```
   from datetime import datetime
   
   def current_datetime():
       return datetime.now().strftime("%Y-%m-%d")
   
   JINJA_CONTEXT_ADDONS = {
       "current_datetime": current_datetime
   }
   ```
   
   Then use in SQLLab
   
   ```
   select ....
   from ....
   where start > {{ current_datetime() }}
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] srinify commented on issue #15613: How do I get current datetime in the SQLTemplate?

Posted by GitBox <gi...@apache.org>.
srinify commented on issue #15613:
URL: https://github.com/apache/superset/issues/15613#issuecomment-877696189


   Was this documentation useful at all?
   
   https://superset.apache.org/docs/installation/sql-templating#available-macros


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org