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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 date conversion

Author  Topic 

purushotham216
Starting Member

14 Posts

Posted - 2009-12-12 : 02:15:42
hi to all thanks in advance

how to convert Dec 11 2009 12:00:00:000AM into 2009-12-11 ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-12 : 02:26:54
select convert(datetime,'Dec 11 2009 12:00:00:000AM',109)
Go to Top of Page

purushotham216
Starting Member

14 Posts

Posted - 2009-12-12 : 02:33:58
thanks visakh ..but i don't want hh:mm:ss (because it is using in searching records based on date)
pls tell me
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-12 : 02:42:23
as long as field is datetime it stores time part also. but you should be worried in storing time part as 00:00:00 as still it will match when you search using date alone. However if your issue is due to non zero time part you can write search condition as

where datefield > @yourpasseddatevalue
and datefield < dateadd(dd,1,@yourpasseddatevalue)

to get all records that belong to a day
Go to Top of Page

purushotham216
Starting Member

14 Posts

Posted - 2009-12-12 : 05:50:24
k thanq it is working
Go to Top of Page
   

- Advertisement -