I have this postgresql query
SELECT pick.min_date, extract('week' from pick.min_date) as week FROM account_invoice inv
left join stock_picking pick on inv.origin=pick.name
WHERE inv.number ='INV/2022/17359'
and the results are
min_date | week
2022-08-11 02:01:00 | 32
What I need for the week column is number 2 because the date (11) is in the 2nd weeks of august. Any help will be great. Thank you
2
Answers
I use date part for these extractions
OUTPUT :
Subtract the week number of the target date from the week number of the first day of the month of the target date and add one. Here is your query with this modification.
Demo