last day
Posted in 1996
Just tried my own date function and realized that it still had a bad piece in it. Replace _current with in_date and it works fine. Maybe it is less efficient than some of the other solutions, but it uses Informix date arithmetic properly and hence does not err. ##################################################################### # # Get the last day of the month. Returns smallint and a date # Jack Parker, Bob Baskett # FUNCTION last_day_month(in_date) DEFINE in_date, out_date DATE, dn INTEGER # what day number is in_date LET dn = DAY(in_date) # 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 out_date = (in_date - dn UNITS DAY + 1 UNITS DAY ) + 1 UNITS MONTH - 1 UNITS DAY # get the day out of that and return. RETURN DAY(out_date), out_date END FUNCTION cheers j. _____________________________________________________________________________ Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA jparker@hpbs3645.boi.hp.com _____________________________________________________________________________ "I'm with the IRS, I'm here to help you" _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________