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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to update based on a date

Status
Not open for further replies.

projecttoday

Programmer
Joined
Feb 28, 2004
Messages
208
Location
US
I have the following:


CurrentDb.Execute "UPDATE tblHoursworked SET weekno = " & weekno & " WHERE starttime = #" & Loopdate & "# AND personid = " & personid


starttime is a Date/Time field which contains a Date/Time (I know the name is a little misleading.) But for this update I want to disregard the time portion. If I use


CurrentDb.Execute "UPDATE tblHoursworked SET weekno = " & weekno & " WHERE Format(starttime,""mm/dd/yyyy"") = #" & Loopdate & "# AND personid = " & personid


it doesn't work. If I use


CurrentDb.Execute "UPDATE tblHoursworked SET weekno = " & weekno & " WHERE DateValue(starttime) = #" & Loopdate & "# AND personid = " & personid


it doesn't work. I'm sure the problem is with the date because


CurrentDb.Execute "UPDATE tblHoursworked SET weekno = " & weekno & " WHERE personid = " & personid


(where I'm leaving out the date check) performs an update but does it for all dates which is not what I need.

How can make this update query select based on the date part of field starttime?

Robert

 
Perhaps this ?
Code:
CurrentDb.Execute "UPDATE tblHoursworked SET weekno = " & weekno & " WHERE Format(starttime,'yyyymmdd') = '" & Format(Loopdate, "yyyymmdd") & "' AND personid = " & personid

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top