DATEADD to change datetimes in SQL Server
0 comments
lauweded19.484 years ago
Basic syntax
DATEADD(<Unit of time>, <Units>, <Date>)
-- Add 5 days to 04/23/2021
DATEADD(DAY, 5, '2021-04-23')
-- Substract 5 days to 04/23/2021
DATEADD(MONTH, -5, '2021-04-23')
Units of time
Unit of time | Abbreviation |
---|---|
NANOSECOND | ns |
MICROSECOND | mcs |
MILLISECOND | ms |
SECOND | ss, s |
MINUTE | mi, n |
HOUR | hh |
WEEKDAY | dw, w |
WEEK | wk, ww |
DAY | dd, d |
DAYOFYEAR | dy, d |
MONTH | mm, m |
QUARTER | qq, q |
YEAR | yy, yyyy |
More information
To get more info on the Docs
Waivio AI Assistant
How can I help you today?
Comments