Collections:
Incrementing or Decrementing Parts of DATETIME Values in SQL Server
How To Increment or Decrement Parts of DATETIME Values in SQL Server Transact-SQL?
✍: FYIcenter.com
If you want to increment or decrement one part of a date and time value, you can use the DATEADD() function in the following format:
DATEADD(datepart, number, date) returns DATETIME: "date" - the input date "number" - the incrementing amount "datepart" - one of predefined date part names
Valid date part names are:
year, yy, yyyy - The year part quarter, qq, q - The quarter part month, mm, m - The month part dayofyear, dy, y - The day-of-year part day, dd, d - The day part week, wk, ww - The week part weekday, dw, w - The weekday part hour, hh - The hour part minute, mi, n - The minute part second, ss, s - The second part millisecond, ms - The millisecond part
For example, DATEADD(year, 1, @birth_date) will increment 1 year to @birth_date.
⇒ DATEADD() Function Usage Examples in SQL Server
⇐ Date and Time Functions Supported by SQL Server 2005 in SQL Server
⇑ Date/Time Operations and Functions in SQL Server Transact-SQL
2017-02-20, 3086🔥, 0💬
Popular Posts:
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
How To Create a Stored Program Unit in Oracle? If you want to create a stored program unit, you can ...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...