DateAdd
Adds offset intervals to a date/time value and returns the new date/time. Use a negative offset to subtract. Interval names are not case-sensitive.
String DateAdd(String dateTime, String interval, Numeric offset)
| Interval | Aliases |
| Year | yy, yyyy |
| Quarter | qq, q |
| Month | mm, m |
| Week | ww, wk |
| Weekday | dw (Monday to Friday) |
| Day | dy |
| DayOfYear | |
| Hour | hh |
| Minute | mi |
| Second | s |
| Millisecond | ms |
Result format
The result uses the server's default date/time format, which depends on its culture settings. Wrap DateAdd in FormatDateTime for a predictable format.SELECT FormatDateTime(DateAdd('2024-01-31', 'Month', 1), 'yyyy-MM-dd') as Result FROM SingleSELECT FormatDateTime(DateAdd(DateTimeUTC(), 'Day', -10), 'yyyy/MM/dd hh:mm:ss tt') as Result FROM SingleSQL :: NullWhenNumeric
Returns null when the number equals compareToValue, otherwise returns the number.
SQL :: Pow
Returns x raised to the power of y.
SQL :: Right
Returns the given number of characters from the end of the value.
SQL :: Round
Rounds a number to the given number of decimal places. Midpoint values are rounded to the nearest even number (2.5 rounds to 2).
SQL :: Scalar Functions
Scalar functions are evaluated once per row.
SQL :: Sha1
Returns the SHA-1 hash of the value's UTF-8 bytes as a lower case hex string.
SQL :: Sha256
Returns the SHA-256 hash of the value's UTF-8 bytes as a lower case hex string.
SQL :: Sha512
Returns the SHA-512 hash of the value's UTF-8 bytes as a lower case hex string.
SQL :: ShowScalarFunctions
Lists the built-in scalar functions with their parameters and descriptions.
SQL :: SubString
Returns length characters of the value, starting at the zero-based startIndex.