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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inserting Non-unix timestamp
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SergioM
Posting Yak Master

170 Posts

Posted - 09/06/2013 :  08:55:53  Show Profile  Reply with Quote
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 - 09/06/2013 :  09:27:32  Show Profile  Reply with Quote
SELECT CONVERT(datetime, REPLACE('Sep-04-13 07:13', '-', ' '), 9);
Go to Top of Page

SergioM
Posting Yak Master

170 Posts

Posted - 09/06/2013 :  10:23:11  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3451 Posts

Posted - 09/06/2013 :  11:40:23  Show Profile  Visit Transact Charlie's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000