Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 date conversion

Author  Topic 

dinesh1968
Starting Member

1 Post

Posted - 2014-12-23 : 10:28:26
hi,

i want to convert the datetime to the integer value as shown within the brackets.

----2014-12-21 0:00:00 (1419091200000)

thks.
dinesh
jain_dinesh@hotmail.com

djain

sz1
Aged Yak Warrior

555 Posts

Posted - 2014-12-23 : 12:25:31
You need to do something like this:


with getstring
As
(
select
Convert(int,convert(varchar(max),getdate(),112)) as [DateKey],
Convert(int,(DATEPART(hour, getdate()) * 10000) + (DATEPART(minute, getdate()) * 100)
+ (DATEPART(Second, getdate()))) AS [TimeKey]
)
--Select cast( Datekey + ' ' + TimeKey as int)
select concat(datekey, timekey) 'combo'
From getstring


We are the creators of our own reality!
Go to Top of Page
   

- Advertisement -