Reputation: 71
I need to get the first day of the week (first day is Sunday) in 'MM/DD/YY format. Here's my Oracle code. I just can't figure out how to in Postgres:
TO_CHAR(TRUNC(column_name + 1,'IW') - 1, 'MM/DD/YY')
Upvotes: 1
Views: 522
Reputation:
Use date_trunc().
date_trunc('week', column_name)
It uses the ISO definition of a week (as does Oracle's 'IW'
) so you need to apply the same date logic you used in Oracle to get the non-standard start of the week:
date_trunc('week', column_name + 1) - 1
Upvotes: 1