Skip to main content
DATE_ADD

Adds a specified offset of time (e.g., seconds, minutes, hours) to a given date or datetime

Updated over a week ago

Description

The DATE_ADD() function enables you to add a specific time offset, such as seconds, minutes, hours, days, months, or years, to a given date or datetime. This function is indispensable for tasks like scheduling events, calculating future dates, or managing time-based data transformations.

Syntax

DATE_ADD(date, offset, "second/minute/hour/day/month/year")

Output

date

Variables

  1. date: The initial date or datetime to which you want to add an offset.

  2. offset: The numeric value representing the quantity of time you want to add.

  3. "second/minute/hour/day/month/year": The unit of time (e.g., seconds, minutes, hours, days, months, years) you want to add to the initial date or datetime.

Example 1

DATE_ADD(`Start Date`, 2, 'hour')

Task

Start Date and Time

DATE_ADD(`Start Date`, 2, 'hour')

Task A

2023-09-10 10:30:00.000

2023-09-10 12:30:00.000

Task B

2023-08-25 04:00:00.000

2023-08-25 06:00:00.000

Task C

2023-09-01 17:15:00.000

2023-09-01 19:15:00.000

Example 2

DATE_ADD(`Start Date and Time`, -1, 'day')

Task

Start Date and Time

DATE_ADD(`Start Date and Time`, -1, 'day')

Task A

2023-09-10 10:30:00.000

2023-09-09 10:30:00.000

Task B

2023-08-25 04:00:00.000

2023-08-24 04:00:00.000

Task C

2023-09-01 17:15:00.000

2023-08-31 17:15:00.000

Did this answer your question?