Wednesday, March 7, 2012

Date format

Hi,
i am storing dates as datetime, so let us say the date is 2004-07-15 11:42:43.780. Now i want to retrieve it exactly like this. Unfortunately it doesnot come out like this.
It is coming out like this Jul 15 2004 11:44AM and i'm losing the seconds
and milliseconds.
Could anyone please advise me how to get 2004-07-15 11:42:43.780.
Thanks in advance.
-ssSelect Convert (varchar, Getdate(), 121)|||Thanks you very much|||Hi experts

Can any one help me !!!

I had also having the same type or problem !

select msgdate from emc_messageinfo

Sql server 2000 returns the following
2004-07-01 15:04:10.000

and i need only the current date means "01-07-2004" ,but not in varchar format i need in date format only so that i can use it further

Thanks and regards

Manish Kaushik|||MS-SQL doesn't distinguish between date and time, there is a single datatype that is DATETIME (and a sub-set of it that is SMALLDATETIME). You can truncate the value to either a date or a time to make computation easier, but you can't truly isolate the date from the time. Try using:SELECT Convert(CHAR(10), Getdate(), 121)-PatP

No comments:

Post a Comment