Jump to Real's How-to Main page

Obtain the last day of a month

Take a date, increment the month, change the day for "01" then decrement by 1.
int li_retdays, li_month, li_year

li_month = Month(ad_date)
li_year = year(ad_date)

IF li_month < 12 THEN
   li_month ++
ELSE
   li_month = 1
   li_year ++
END IF

// build a new date
ld_newdate = date(li_year),li_month,1)
// extract the last day of the previous month
ld_previousmonthlastday = Day(RealtiveDate(ld_newdate, -1))

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]