Re: Last day of month..
Posted in 1998
Louis DeLongchamp wrote: > > >SUNIL S. SINGH wrote: > > > >Hi All !! > > > >Is there any function or technique to find last day of month > >ie 29 or 28 or 30 or 31 for a particular date(dd/mm/yy) > > > You don't know how many days are in a month, but you know that the first day of every month is numbered with a 1. To get the number of the last day in a month, subtract one day from the first day of next month. In unix C: unsigned int lastday(const time_t t) { /* * compute the day before the first day of next month */ struct tm lt; unsigned int lday; time_t ttime; localtime_r(&t, <); lt.tm_mday = 1; ++lt.tm_mon; ttime = mktime(<) - 60*60*24; localtime_r(&ttime, <); return lt.tm_mday; } -- William Warner bill.warner@attws.com