cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kmflanagan
Level: Powered On

DateAdd formula formula won't work

I am trying to add hours to a start time to mark the end of an appointment (meeting starts at 2:00PM and ends at 3:00PM).  I've created a drop down with 1/2 hour increments and after the selection is made, I wish to add the duration time (stored in a seperate control), to the start time to get the end.

 

I have entered this formula into a seperate control to get my time:

 

DateAdd(TimeValue(ddSelectTime.Selected.Value), Value(txtDuration.Text), Hours).

 

If I change the bolded/underlined section in the above formula to Now(), it works great.  Help!!!

Capture.JPG

2 ACCEPTED SOLUTIONS

Accepted Solutions
samuelJ
Level 8

Re: DateAdd formula formula won't work

I believe you need to enter a DateTime value.  If I am understanding your code correctly:

ddSelectTime.Selected.Value

is just the value: "7:30 AM".  You should pass the full DateTime: "12/28/2018 7:30AM".  

 

kmflanagan
Level: Powered On

Re: DateAdd formula formula won't work

Thank you for the response and indeed, that was the problem.  I got so focused on needing the time to change, I forget to pass the date!!!

 

Thanks for your help!

2 REPLIES 2
samuelJ
Level 8

Re: DateAdd formula formula won't work

I believe you need to enter a DateTime value.  If I am understanding your code correctly:

ddSelectTime.Selected.Value

is just the value: "7:30 AM".  You should pass the full DateTime: "12/28/2018 7:30AM".  

 

kmflanagan
Level: Powered On

Re: DateAdd formula formula won't work

Thank you for the response and indeed, that was the problem.  I got so focused on needing the time to change, I forget to pass the date!!!

 

Thanks for your help!