Collections:
Adding and Removing Days on Date and Time Values in SQL Server
How To Add or Remove Days on Date and Time Values in SQL Server Transact-SQL?
✍: FYIcenter.com
SQL Server 2005 only support two operators on data and time values:
Note that to add or subtract days on a date and time value, the other operand must be a numeric value: an integer or a decimal number.
Here are some good examples of adding days to and subtracting days from date and time values:
-- Leap year is supported DECLARE @birth_date DATETIME; SET @birth_date = '29-Feb-2000 03:00:00.000'; SELECT @birth_date + 1; SELECT @birth_date - 1; GO 2000-03-01 03:00:00.000 2000-02-28 03:00:00.000 -- Partial days are supported DECLARE @birth_date DATETIME; SET @birth_date = '29-Feb-2000 03:00:00.000'; SELECT @birth_date + 0.5; -- adding a half day SELECT @birth_date + 1.0/3; GO 2000-03-01 15:00:00.000 2000-02-29 10:59:59.970
⇒ Converting Date and Time Values into Integers in SQL Server
⇐ Verify Time Precision in SQL Server Transact-SQL
⇑ Date/Time Operations and Functions in SQL Server Transact-SQL
2017-02-22, 1552🔥, 0💬
Popular Posts:
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
How To List All Stored Procedures in the Current Database in SQL Server Transact-SQL? If you want to...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
How To Insert New Line Characters into Strings in SQL Server Transact-SQL? If you want to break a st...
What Is an Oracle Instance in Oracle? Every running Oracle database is associated with an Oracle ins...