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 2000 Forums
 SQL Server Development (2000)
 Update Date field

Author  Topic 

vbtest5
Starting Member

1 Post

Posted - 2006-03-31 : 01:42:09
Hello,

We have a date field in our table. When records were inserted, we insert current system date. Due to this, along with date, time also got inserted. Now If I try to generate a report and group by this date field, the records for same date do not get summed into one single record due to this time value in this field.

What query should I write to that date field is set to only date (need to remove tim)?
For Example: 12/12/2006 12:23:55 should be updated as 12/12/2006? This will help me do a group by on this date field.

Regards,
VJ

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-31 : 02:07:03
use this dateadd(day, datediff(day, 0, getdate()), 0) to remove the time when you insert.

update yourtable
set datefield = dateadd(day, datediff(day, 0, datefield), 0)




KH

Choice is an illusion, created between those with power, and those without.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-31 : 02:56:23
Dont update date column. Let it has Date with Time. In your Report format the datetime column to have mm/dd/yyyy format and group that

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -