I'm looking for C code that will give me the last day of the month.
Input - any day that I pass in as a variable....
input = 20050201
Output - calculate and format with slashes....
output = 2005/02/28
From my date library documentations:
---------------------------------------------------------------
last_day_of_month()
---------------------------------------------------------------
NAME:
last_day_of_month() - Computes a date value for the last day
of the month.
SYNOPSIS:
#include "datetool.h" or "toolbox.h"
date_t last_day_of_month( date_t date_value );
DESCRIPTION:
The last_day_of_month() function uses the date_value argument to
compute a date value which is the last day of the month in which
the date_value argument falls. For example, if the date_value
argument were for Monday, 14 February 1994 the last_day_of_month()
function would calculate a date value for Monday, 28 February 1994.
The date_value argument is checked to be a valid date value between
01/01/0001 A.D. and 12/31/9999 A.D.
ARGUMENTS:
A valid date value between 01/01/0001 A.D. and 12/31/9999 A.D.
RETURN VALUE:
A date value representing the last day of month in which the
argument falls. A value of (date_t) -1L is returned when the
date_value argument is invalid.
SEE ALSO:
first_day_of_month(), date().