Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updateing time

Status
Not open for further replies.

NeilV

Programmer
Oct 14, 2002
117
GB
Hello!

I am trying to update the hour/min part of a datetime field, i can update it using the dateadd funtion:
Update shiftCalculator set Rotation_Time =dateadd(hh,8,Rotation_Time)
this works fine if I want to advance current time by a certain amount, but how can i set it to a specific value? I have tried:
update shiftcalculator set datepart(hh,rotation_time) = 8
in an attempt to set the hour value to 8, but it does not work.

Help!

Neil
 
This is a bit messy, but it would take your time down to midnight (00:00:00), then add eight hours onto the result.

Code:
dateadd(hh,8,convert(smalldatetime,convert(char(10),getdate(),103)))
 
This is a bit messy, but it would take your time down to midnight (00:00:00), then add eight hours onto the result.

Code:
dateadd(hh,8,convert(smalldatetime,convert(char(10),Rotation_Time,103)))

mrees
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top