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
 Inserting Non-unix timestamp

Author  Topic 

SergioM
Posting Yak Master

170 Posts

Posted - 2013-09-06 : 08:55:53
Is it possible to insert a timestamp into a db if it's in this format?

Sep-04-13 07:13

I don't need it to stay in this format. I just need to know if I can cast it as a unix timestamp somehow & insert or if the manipulation to the datetime fomrat has to happen before inserting.

-Sergio
I use Microsoft SQL 2008

Ifor
Aged Yak Warrior

700 Posts

Posted - 2013-09-06 : 09:27:32
SELECT CONVERT(datetime, REPLACE('Sep-04-13 07:13', '-', ' '), 9);
Go to Top of Page

SergioM
Posting Yak Master

170 Posts

Posted - 2013-09-06 : 10:23:11
quote:
Originally posted by Ifor

SELECT CONVERT(datetime, REPLACE('Sep-04-13 07:13', '-', ' '), 9);


Woot! Thanks. I keep finding results on Google about how to query the db & convert. I was starting to lose hope

-Sergio
I use Microsoft SQL 2008
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2013-09-06 : 11:40:23
its best to use the ISO date format strings - everything else has a chance of confusion cross locales or languages

formats are: YYYYMMDD or YYYY-MM-DDTHH:MM:SS.msmsZ


Transact Charlie
Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
http://nosqlsolution.blogspot.co.uk/
Go to Top of Page
   

- Advertisement -