You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/11/30 12:58:47 UTC

[GitHub] [drill] cgivre commented on issue #2390: add time unit WEEK to EXTRACT()

cgivre commented on issue #2390:
URL: https://github.com/apache/drill/issues/2390#issuecomment-982612288


   @pandalanax 
   Thanks for your interest in Drill!  You might want to take a look at the `nearestdate()` function. [1]
   This has similar functionality to what you're describing although I do agree it would be good to add the `WEEK` to the `EXTRACT` function.
   
   For example, you could do the following query:
   
   ```sql
   SELECT nearestdate(CURRENT_DATE, 'WEEK_SUNDAY') AS current_week 
   FROM ...
   ```
   If you wanted the week number you could wrap this in the `TO_DATE` function like this:
   
   ```sql
   SELECT TO_DATE(nearestDate(CURRENT_DATE, 'WEEK_SUNDAY'), 'w') AS week_num
   FROM ....
   ```
   
   
   [1]: https://drill.apache.org/docs/date-time-functions-and-arithmetic/#nearestdate


-- 
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: dev-unsubscribe@drill.apache.org

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