The examples above show both adding and subtracting from the date which is what is done in the HOUR example. A positive number to add and a negative number to subtract. Wednesday, Janu8:59:37 AM - Greg Robidoux It is "yyyy-mm-dd", with the dashes we made this decision so that the display be unambiguous and could always be parsed correctly.
The only display format allowed for dates in the ANSI ISO standards for SQL is based on ISO – 8601. The start and end time in seconds, then adding the number of seconds to ,
SQL Server DATEADD Function Examplesįor all of these Transact-SQL examples, the parameter = " 15:48:39.2370000",Ī practical use of DATEADD is to return a user-friendly length of time that hasĮlapsed between two times, like how long it takes for a student to complete an exam.īelow we are also using the DATEDIFF function to find the difference between Of time were introduced as well, but cannot be used in earlier versions of SQL Server.Īnother thing to keep in mind is that you can't use the seconds unit of time with SQL Server 2008 and later introduced new date/timeĭata types: DATETIME2, TIME, and DATETIMEOFFSET. The table above reveals that there are some units of time that cannot be used
Here are the units of time, the SQL Server versions in which they can be used,Īnd abbreviations that can be used instead of the full unit of time name: Units of Time Available in SQL Server