Last day of the month
Posted in 1994
Cute function. Ever wonder how many days in a month there were? Remember when we used to have to do all kinds of wierd date math to figure it out or lists of months and stuff? Try this. # Get the last day of the month. FUNCTION last_day() DEFINE ld DATE, dn INTEGER # what day number is today? LET dn = DAY(CURRENT) # subtract that many days yields last day last month. # add 1 day gives first day this month # add 1 month gives first day next month # subtract 1 day gives last day this month. # this is different from last_day last month + 1 month --> 30 vs 31. LET ld = (TODAY - dn UNITS DAY + 1 UNITS DAY ) + 1 UNITS MONTH - 1 UNITS DAY # get the day out of that and return. RETURN DAY(ld) END FUNCTION cheers j. _____________________________________________________________________________ Jack Parker | Hewlett Packard, BSMC Boise, Idaho, USA| BEER jparker@hpbs3645.boi.hp.com | It's not just for breakfast anymore. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________