April 2008
Intermediate to advanced
566 pages
21h 55m
English
MAKEDATE()
MAKEDATE(year,days)
This function determines the date requested from the start of
the given year, by adding the number of days given in the second
argument. It returns the date in the
yyyy-mm-dd format. It returns NULL if a
value given for days is not greater than 0. It
will accept more than a year’s worth of days, though. It just returns
a date into the next year or whatever year is appropriate, based on
however many days the result is from the beginning of the year given.
This function is available as of version 4.1.1 of MySQL. Here is an
example:
SELECT MAKEDATE(2009, 1) AS 'First Day', MAKEDATE(2009, 365) AS 'Last Day', MAKEDATE(2009, 366) AS 'One More Day'; +------------+------------+--------------+ | First Day | Last Day | One More Day | +------------+------------+--------------+ | 2009-01-01 | 2009-12-31 | 2010-01-01 | +------------+------------+--------------+
Read now
Unlock full access