dbTalk Databases Forums  

Add a Duration to a Time

comp.databases.ms-access comp.databases.ms-access


Discuss Add a Duration to a Time in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Keith Wilby
 
Posts: n/a

Default Add a Duration to a Time - 01-22-2008 , 03:50 AM






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.


Reply With Quote
  #2  
Old   
Keith Wilby
 
Posts: n/a

Default Re: Add a Duration to a Time - 01-22-2008 , 04:00 AM






"Keith Wilby" <here (AT) there (DOT) com> wrote

Quote:
What forehead slappingly obvious trick am I missing?

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



Reply With Quote
  #3  
Old   
Allen Browne
 
Posts: n/a

Default Re: Add a Duration to a Time - 01-22-2008 , 04:24 AM



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 (DOT) com> wrote

Quote:
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.


Reply With Quote
  #4  
Old   
Keith Wilby
 
Posts: n/a

Default Re: Add a Duration to a Time - 01-22-2008 , 05:48 AM



"Allen Browne" <AllenBrowne (AT) SeeSig (DOT) Invalid> wrote

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

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

Thanks Allen.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.