Reputation: 25366
I am using the following query to change all date to the Monday of the corresponding week:
select date_trunc('week', join_date) as join_wk from my_table
This query converts 2017-08-23 11:30:02
to 2017-08-21 00:00:00
I am wondering if it is possible to remove the hour/min/second
from the output 2017-08-21 00:00:00
? i.e. make the output in the format of 2017-08-21
Upvotes: 2
Views: 852
Reputation: 311188
date_trunc
returns a timestamp
. You could cast it to a date
to lose the time part of it:
SELECT DATE_TRUNC('week', join_date)::DATE AS join_wk FROM my_table
-- Here ----------------------------^
Upvotes: 3