------Convert from datetime to date -SQL Server 2008
DECLARE @date Date
Declare @datetime datetime
SELECT @datetime = GETDATE(), @date = @datetime
SELECT @date AS 'date', @datetime AS 'datetime'
------/Convert from datetime to time-SQL Server 2008
DECLARE @time time, @datetime datetime
SELECT @datetime = GETDATE(), @time = @datetime
SELECT @time AS 'time', @datetime AS 'datetime'
------Convert from datetime to datetime2-SQL Server 2008
DECLARE @datetime2 datetime2, @datetime datetime
SELECT @datetime = GETDATE(), @datetime2 =
@datetime SELECT @datetime2 AS 'datetime2', @datetime
AS 'datetime'
------Convert from time to datetime-SQL Server 2008
DECLARE @time time(4), @datetime datetime
SELECT @time = '10:11:12.1234', @datetime =
@time SELECT @time AS 'time', @datetime AS 'datetime'
------Convert from date to datetime-SQL Server 2008
DECLARE @date date, @datetime datetime
SELECT @date = '01-11-10', @datetime = @date
SELECT @date AS 'date', @datetime AS 'datetime'
------Convert from datetime2 to datetime-SQL Server 2008
DECLARE @datetime2 datetime2, @datetime datetime
SELECT @datetime2 = GETDATE(), @datetime =
@datetime2 SELECT @datetime AS 'datetime',
@datetime2 AS 'datetime2'
No comments:
Post a Comment