The information in this article applies to:
SUMMARYThe following information discusses how to convert CHAR values into DATETIME values so that a SMALLINT value can be subtracted and a START_TIME value can be obtained. MORE INFORMATION
To begin with, the character date and time must be converted into the
SQL Server datetime format. Then the SMALLINT value can be subtracted
to obtain START_TIME. Both tasks can be performed in a single SQL
expression; however, it is easier to understand the process if both
tasks are considered separately.
Given a date in SQL Server datetime format, it is easy to add or subtract a given amount of seconds, minutes, days, and so forth. For example, assuming the SMALLINT value ("@delta") is in seconds, the following function will return the start date/time:
The entire expression can be put into the following select statement so it is executed for each row in the input table. "@delta" is assumed to be an input parameter. If "@delta" is in units other than seconds, the first parameter of dateadd must be changed to reflect the correct units (minutes, days, and so forth).
Additional query words: Transact-SQL Windows NT
Keywords : kbprg SSrvTran_SQL SSrvWinNT |
Last Reviewed: March 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |