Add a Duration to a Time

Add a Duration to a Time

am 22.01.2008 10:50:10 von Jebusville

Here's something I thought I'd know how to do ...

I have an Appointments table and want to add a duration (integer
representing hours) to a start time (Date/Time field, "Short Time" format)
to give a finish time. I want to do this in a query but if I do
[StartTime]+[Duration] I get a date returned. I've tried using the Format
function to no avail.

What forehead slappingly obvious trick am I missing?

Thanks.

Keith.

Re: Add a Duration to a Time

am 22.01.2008 11:00:39 von Jebusville

"Keith Wilby" wrote in message
news:4795b871$1_1@glkas0286.greenlnk.net...
>
> What forehead slappingly obvious trick am I missing?
>

[Duration]/24 seems to work but there must be a more elegant solution ...

Re: Add a Duration to a Time

am 22.01.2008 11:24:06 von Allen Browne

Keith, try:
DateAdd("h", [Duration], [AppointmentTime])

Since Duration is an integer in hours, that should do it.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" wrote in message
news:4795b871$1_1@glkas0286.greenlnk.net...
> Here's something I thought I'd know how to do ...
>
> I have an Appointments table and want to add a duration (integer
> representing hours) to a start time (Date/Time field, "Short Time" format)
> to give a finish time. I want to do this in a query but if I do
> [StartTime]+[Duration] I get a date returned. I've tried using the Format
> function to no avail.

Re: Add a Duration to a Time

am 22.01.2008 12:48:08 von Jebusville

"Allen Browne" wrote in message
news:4795c449$0$17235$5a62ac22@per-qv1-newsreader-01.iinet.n et.au...
> Keith, try:
> DateAdd("h", [Duration], [AppointmentTime])
>
> Since Duration is an integer in hours, that should do it.
>

Thanks Allen.