I have a column in my table with the name: efcodmov, every start of the month I need to extract all registers from the last month
end of the code:
AND efdtmov BETWEEN date('2023-01-01') AND date('2023-01-31')
How can I modify to do automatically?
3
Answers
Lazy way:
Assumes you run within 10 days of month’s start.
More stable, but bulkier, way:
You can compare the year and month only as follows :
Use date manipulation functions, specifically
date_trunc
to truncate both dates to the same unit: