{"id":157,"date":"2012-04-19T05:11:09","date_gmt":"2012-04-19T05:11:09","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/04\/19\/convert-datetime-to-timestamp\/"},"modified":"2012-04-19T05:11:09","modified_gmt":"2012-04-19T05:11:09","slug":"convert-datetime-to-timestamp","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/04\/19\/convert-datetime-to-timestamp\/","title":{"rendered":"Convert DateTime To TimeStamp"},"content":{"rendered":"

How to Convert DateTime To TimeStamp?<\/strong><\/p>\n

Using CAST(DateTime<\/strong> AS TIMESTAMP).<\/p>\n

Below query shows how you can convert datetime to timestamp.<\/p>\n

[sql]
\nDECLARE @DateTimeVariable DATETIME<\/p>\n

SELECT @DateTimeVariable = GETDATE()<\/p>\n

SELECT @DateTimeVariable AS DateTimeValue,
\n CAST(@DateTimeVariable AS TIMESTAMP) AS DateTimeConvertedToTimestampCAST<\/p>\n

–Alternate Approach
\nSELECT @DateTimeVariable AS DateTimeValue,
\n CONVERT(TIMESTAMP, @DateTimeVariable ) AS DateTimeConvertedToTimestampCONVERT
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"

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]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[1592,1593,1594,1595,1596,1597,1598,1599],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/157"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}