DATETIME
Posted in 1995
> > Has anyone written a function to handle this that they can share? I wrote > one once at another site but never saved it. > The following function was posted some time ago. It serves as the core for solving your problem (you can figure out how to do whatever YOU want to do w/ regard to this scenario from the code herein): --- 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 j. _____________________________________________________________________________ Jack Parker - Hewlett Packard, BSMC Boise, Idaho, USA jparker@hpbs3645.boi.hp.com _____________________________________________________________________________ Subtlety is the art of saying what you think and getting out of the way before it is understood. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________