October 30, 2009 at 7:36 am
Susan,
You list 06-30-2007 and 2007-10-10 as the format.
Not sure if this will help as it is an answer that has only been checked for SQL Server 2008. (not to mention it is after the fact - but I found your post) I added the time as well just to extend the metaphor a bit.
declare @date datetime
select cast(CONVERT(varchar(30),'20070630 23:00',130) as DATETIME)
set @date =CONVERT(varchar(30),'20070630 23:00',130)
select @date
SELECT CONVERT(datetime,@date)
select CONVERT(decimal(13,4),CONVERT(datetime,@date))
You get several answers in this manner - including a one I find particularly appealing - storing the date in decimal format (Please note it is only accurate to the nearest 400 ns).
There is an 8601 ISO standard that may help to alleviate the formatting somewhat - you may want to check this as well.
http://technet.microsoft.com/en-us/library/ms180878.aspx
Jamie
Jamie
September 4, 2012 at 11:31 am
Take a good look at your table columns, you might be converting a non date type to date datatype
September 5, 2012 at 3:39 am
zyzy (9/4/2012)
Take a good look at your table columns, you might be converting a non date type to date datatype
You just answered a post which is three years old... 🙂
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
September 5, 2012 at 7:41 am
Phil Parkin (9/5/2012)
zyzy (9/4/2012)
Take a good look at your table columns, you might be converting a non date type to date datatypeYou just answered a post which is three years old... 🙂
If it's the right answer, does it matter?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply