4thSpace
4thSpace

Reputation: 44352

How to update time value?

I have several datetime entries that I need to replaced the time part with the midnight value - '00:00:00.000'.

How do I update only the time part of a datetime value? The date needs to be retained.

Upvotes: 0

Views: 292

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

The easiest way is to cast to a date and then back again:

select cast(cast(col as date) as datetime)

or

update t
    set col = cast(col as date);

Upvotes: 3

Related Questions