End of month function

End of month function

Post by Ian Sweene » Sat, 31 Jan 1998 04:00:00



SELECT DATE_TRUNC('month', DATE('17/01/1997') + '1 month') - '1 day'

returns '31/01/97'

Is there a more efficient way to get the last day of the month for any
given date?

 
 
 

1. Last Day of Month, End of Month, First Day of Month

I searched all over google for answers to this question and came across many
solutions. But converting dates to character and plugging a "01" in and
putting the date back together seemed to old school.

Ex..



Or maybe it had a different purpose that I didn't catch in the thread. But
tinkering with Healthcare data has caused me to tinker with dates more than
I could care for.

I figure I would just post this incase someone else needed a simple solution
that didn't eat up the runtime of the query.

/*CurrentMonth is set to the first day of the month*/


/*Figure out the last day of the current month */


/*Figure out the last day of the previous month */


Not to mention storing all of these little bits of code in the newsgroup
allows me to find them in the future from anywhere.

2. Dump/Load/IdxBuild statistics

3. Months Months Months

4. Redo record at high number

5. end of month

6. complie error on windows

7. Trying to calculate beginning and ending of month

8. US-CO-NATIONAL GIS DESKTOP DEVELOPERS - 014PROS

9. Calculating month end

10. End of month date

11. Help: Tasks not continued after month-end

12. sql for end-month data extracting

13. Calculating End Of Month...