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 :: Syntax
Basic KBSQL syntax and some examples.
SQL :: ToLower
Returns the value converted to lower case.
SQL :: ToNumeric
Returns the value converted to a number.
SQL :: ToProper
Returns the value with the first letter of each word capitalized (title case).
SQL :: ToString
Returns the number as a string, so that + concatenates it instead of adding it.
SQL :: ToUpper
Returns the value converted to upper case.
SQL :: Trim
Removes white space from the start and end of the value. When characters is given, each of those characters is removed from the start and end instead.