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 SingleHome
The home page
SQL :: Abs
Returns the absolute value of a number.
SQL :: Ceil
Returns the smallest whole number that is greater than or equal to the given number.
SQL :: Checksum
Returns a simple 16-bit checksum (0 to 65535) of the value's ASCII bytes. It is fast but not collision resistant; use Sha256 when the value must be unique.
SQL :: Coalesce
Returns the first of the given values that is not null. Accepts any number of values.
SQL :: Concat
Concatenates all of the given values that are not null. Accepts any number of values. The + operator can also be used to concatenate, but a null on either side of + makes the whole result null.
SQL :: DateDiff
Returns the number of intervals between two date/time values (date2 minus date1). See DateAdd for the interval names.
SQL :: DateTime
Returns the server's current local date and time, formatted with the optional .NET date/time format string.
SQL :: DateTimeUTC
Returns the current UTC date and time, formatted with the optional .NET date/time format string. See DateTime for the format specifiers.
SQL :: Expressions
Literals, operators, comments and variables in KBSQL.