Introduction
Date functions are used to perform operations on date values in databases, spreadsheets, and programming languages. They help you extract, manipulate, and format dates for reporting, calculations, and automation. Understanding these functions is essential for working efficiently with data that involves dates.
Common Date Functions
1. TODAY()
- Returns the current date.
- Example:
=TODAY()→ 2026-03-06
2. NOW()
- Returns the current date and time.
- Example:
=NOW()→ 2026-03-06 14:35
3. DATE(year, month, day)
- Creates a date from individual year, month, and day values.
- Example:
=DATE(2026, 3, 6)→ 2026-03-06
4. DAY(date)
- Extracts the day of the month from a date.
- Example:
=DAY("2026-03-06")→ 6
5. MONTH(date)
- Extracts the month number from a date.
- Example:
=MONTH("2026-03-06")→ 3
6. YEAR(date)
- Extracts the year from a date.
- Example:
=YEAR("2026-03-06")→ 2026
7. WEEKDAY(date)
- Returns a number representing the day of the week.
- Example:
=WEEKDAY("2026-03-06")→ 6 (if Sunday is 1)
8. DATEVALUE(text)
- Converts a text string representing a date into a date value.
- Example:
=DATEVALUE("6-Mar-2026")→ 2026-03-06
9. DATEDIF(start_date, end_date, unit)
- Calculates the difference between two dates.
- Units can be: “D” (days), “M” (months), “Y” (years)
- Example:
=DATEDIF("2025-03-06", "2026-03-06", "Y")→ 1
10. EOMONTH(start_date, months)
- Returns the last day of the month after adding a specified number of months.
- Example:
=EOMONTH("2026-03-06", 1)→ 2026-04-30
Formatting Dates
- Dates can be displayed in various formats:
dd/mm/yyyy,mm/dd/yyyy,yyyy-mm-dd. - Use formatting options to display dates according to your requirements.
Practical Uses
- Calculating age from a birthdate
- Determining due dates for tasks or invoices
- Finding the number of days between two events
- Automating monthly reports and dashboards
Tips
- Always check the system’s default date format.
- When working with text-based dates, use
DATEVALUEto avoid errors. - Combine
DATEwith other functions to perform advanced calculations.