Convert DateTime To TimeStamp

Posted on : 19-04-2012 | By : Devi Prasad | In : SQL Server Basics

Share:

0


How to Convert DateTime To TimeStamp?

Using CAST(DateTime AS TIMESTAMP).

Below query shows how you can convert datetime to timestamp.

DECLARE @DateTimeVariable DATETIME

SELECT @DateTimeVariable = GETDATE()

SELECT @DateTimeVariable AS DateTimeValue,
       CAST(@DateTimeVariable AS TIMESTAMP) AS DateTimeConvertedToTimestampCAST

--Alternate Approach
SELECT @DateTimeVariable AS DateTimeValue,
       CONVERT(TIMESTAMP, @DateTimeVariable ) AS DateTimeConvertedToTimestampCONVERT
(Visited 5,870 times, 5 visits today)



References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Write a comment



Tags: , , , , , , ,