Add a Duration to a Time

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.
Jebusville [ Di, 22 Januar 2008 10:50 ] [ ID #1913830 ]

Re: Add a Duration to a Time

"Keith Wilby" <here [at] there.com> wrote in message
news:4795b871$1_1 [at] glkas0286.greenlnk.net...
>
> What forehead slappingly obvious trick am I missing?
>

[Duration]/24 seems to work but there must be a more elegant solution ...
Jebusville [ Di, 22 Januar 2008 11:00 ] [ ID #1913831 ]

Re: Add a Duration to a Time

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" <here [at] there.com> wrote in message
news:4795b871$1_1 [at] 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.
Allen Browne [ Di, 22 Januar 2008 11:24 ] [ ID #1913832 ]

Re: Add a Duration to a Time

"Allen Browne" <AllenBrowne [at] SeeSig.Invalid> wrote in message
news:4795c449$0$17235$5a62ac22 [at] 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.
Jebusville [ Di, 22 Januar 2008 12:48 ] [ ID #1913834 ]
Datenbanken » comp.databases.ms-access » Add a Duration to a Time

Vorheriges Thema: Print a string variable
Nächstes Thema: How to define an Array in VBA behind the Access Forms