DateAdd


P

PeterM

I have a field in a table that is set to a general number format called
txAlarmDateTime. On a form I have a separate start date (StartDate) and a
separate start time (StartTime). I need to populate the txAlarmDateTime
with a concatination of the StartDate and StartTime.

I want to add 30 minutes to the StartTime and have the following code.

Me.txAlarmDateTime = DateAdd("n", 30, Me.StartTime)

The problem I'm having is that it does add 30 minutes to the StartTime but
the date is 12/31/1899. If the StartTime is 11:00AM and the StartDate is
1/6/2010 then the resulting value is "12/31/1899 11:30AM" but it should be
"1/6/2010 11:30AM".

What am I doing wrong?
 
Ad

Advertisements

J

John Spencer

Try
Me.txAlarmDateTime = DateAdd("n", 30, Me.StartDate + Me.StartTime)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
T

Tom Wickerath

Hi Peter,

It seems to me like it is doing exactly what you asked it to do....add 30
minutes to the StartTime value. You didn't include StartDate in your
expression. Have you tried this?

Me.txAlarmDateTime = DateAdd("n", 30, Me.StartTime + Nz(Me.StartTime,0))

I threw in the Nz (Convert from null) just in case you have not entered a
StartTime. I haven't taken the time to test this, to see if it actually
works, but offhand me thinks it should work.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
Ad

Advertisements

Ad

Advertisements


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

Top