September 3, 2010 at 9:54 am
I want to update all Start_date fields that have a time of 00:00:00.000 to 07:00:00.000. If I try and do a like on a time field, i.e. where Staret_date like '%00:00:00.000' it doesn't work.
Before:
Start_date........................
2010-06-17 07:00:00.000
2010-08-01 00:00:00.000
2010-07-01 07:00:00.000
After:
Start_date........................
2010-06-17 07:00:00.000
2010-08-01 07:00:00.000
2010-07-01 07:00:00.000
September 3, 2010 at 9:57 am
you could cast the datetime to time for the where clause
where cast(start_date as time) = '00:00:00.0000000'
September 3, 2010 at 10:00 am
update MyTable
set
StartDate = dateadd(dd,datediff(dd,0,StartDate),'07:00:00.000')
where
StartDate = dateadd(dd,datediff(dd,0,StartDate),0)
September 3, 2010 at 10:03 am
That worked great - thank you very much.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply