The
TODATETIMEOFFSET
Function
The TODATETIMEOFFSET function sets the time zone offset of an input date and time value.
Syntax
TODATETIMEOFFSET(date_and_time_value, time_zone)
This function is different from SWITCHOFFSET in that its first input will usually be a date and time
type that is not offset aware. This function simply merges the input date and time value with the
specified time zone offset to create a new datetimeoffset value.
You will typically use this function when migrating non-offset-aware data to offset-aware data.
Imagine that you have a table holding local date and time values in an attribute called dt of a
DATETIME data type and the offset in an attribute called theoffset. You then decide to merge the
two to one offset-aware attribute called dto. You alter the table and add the new attribute. Then
you update it to the result of the expression TODATETIMEOFFSET(dt, theoffset). Then you can
drop the two existing attributes dt and theoffset.
The
DATEADD
Function
The DATEADD function allows you to add a specified number of units of a specified date part to an
input date and time value.
www.it-ebooks.info
84
Microsoft SQL Server 2012 T-SQL Fundamentals
Syntax
DATEADD( Do'stlaringiz bilan baham: |