DATE
Creates a date from year, month, and day values. Use DATE when you need to construct a specific date from individual components, like setting a fixed deadline or building dates from user input.
Syntax
DATE(year, month, day)year(Number): Four-digit year (e.g., 2024)month(Number): Month from 1-12 (January = 1, December = 12)day(Number): Day of the month (1-31)
Returns
Date object representing the specified date.
Examples
Set a fixed deadline
DATE(2024, 12, 31)Returns December 31, 2024.
Build date from user input
DATE(YEAR_INPUT, MONTH_INPUT, DAY_INPUT)Combines separate year, month, and day fields into a single date value.
Calculate next tax deadline
DATE(YEAR(CURRDATE()), 4, 15)Returns April 15th of the current year.
Set product launch date
LAUNCH_DATE = DATE(2024, 10, 15)
DAYS_UNTIL_LAUNCH = DAYS(CURRDATE(), LAUNCH_DATE)Months are 1-indexed: January = 1, December = 12. Using 0 or 13 will cause errors.
DATE creates a date-only value. If you need to include time, use DATETIME instead.
Common Patterns
First day of current month:
DATE(YEAR(CURRDATE()), MONTH(CURRDATE()), 1)Last day of year:
DATE(YEAR(CURRDATE()), 12, 31)Birthday this year:
DATE(YEAR(CURRDATE()), BIRTH_MONTH, BIRTH_DAY)Common Mistakes
Using month 0: January is 1, not 0. DATE(2024, 0, 1) errors.
Invalid day for month: DATE(2024, 2, 30) errors (February doesn't have 30 days).
Two-digit years: Use four digits. DATE(24, 1, 1) may give unexpected results.
See Also
DATETIME · CURRDATE · ADDDAYS · ADDMONTHS · ADDYEARS