sql update only time portion of Date field

  • Thread starter Thread starter welyakim
  • Start date Start date
W

welyakim

Is there a way to update the time portion only of a date field? I am
trying to do this with an sql update but I can't get the syntax
correct. Either I get a syntax error or a type conversion error.

Specificaly, I have a meeting schedule which includes a series of
recurring meetings. I am trying to update only the time of the meeting,
but not the actual dates.

I have tried using an update statement with the format function, but I
just can't get it right.

Thanks for your help.
 
Hi.

Search Access Help on the DateAdd function. You can use this function in
your SQL to add or subtract any amount of time you like. For example, to add
1 hour to the time in a field named DateTimeField:

DateAdd("h",1,[DateTimeField])

-Michael
 
You can return the date/time value with a zero time of day using the
DateValue function. You then just need to add the new time of day to this if
you want to update the date/time values to an absolute time of day rather
than one relative to the existing value, e.g. to update each to 3.00 PM:

UPDATE MyTable
SET MyDateTime =
DATEVALUE(MyDateTime) + #15:00:00#;

Ken Sheridan
Stafford, England
 
Thanks Ken!
The DATEVALUE function is exactly what I was looking for and I didn't
know about the + syntax for dates!

-Elie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top