Convert DateTime To TimeStamp

How to Convert DateTime To TimeStamp?

Using CAST(DateTime AS TIMESTAMP).

Below query shows how you can convert datetime to timestamp.

[sql]
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
[/sql]