Re: Last day of the month??
Posted in 1996
darrell@gteens.com (Darrell S. Thacher) wrote: >At 6:30 PM 2/8/96, Ramki Natesan wrote: >>Hi, >> Is there any Informix lib function to get last day of the >> month? or how do get that? could someone help? >> >>Thanks in advance. >> >>-Ramki > >Ramki, > >Here's a function where I set global variables to the 1st and last day of >the current month. > >For the last day of the month I set an Informix date variable to the 1st >day of the next month. Then I just subtract 1 from the date which gives >you the last day of the current month without having to know the number of >days in the month, leap year status, etc. You'll note that all my code >treats years using all 4 digits! >... A simpler solution might be as follows (untested): function lastday(dat) define dat date, mon datetime year to month let mon = dat + 1 units month -- Set month variable to next month let dat = mon -- Set date to the first of next month return (dat - 1) -- Return the last day of current month end function This function avoids problems that might occur with the DBDATE environment variable when using char variables. -- John H. Frantz Power-4gl: Extending Informix-4gl frantz@centrum.is http://www.strengur.is/~frantz/pow4gl.html