Add day to current day.

A

Antonio

Is there an expression that can be used to change the
current date of a "date" field to the following days date
after a specific hour of time? If no expression, can some
sort of code be written to do the job?

Example:
All entries between 04:00AM and 10:29 PM = Date()
All entries 10:30 PM and 11:59 PM = Date()+1

thanks in advance.
 
W

Wayne Morgan

In the Before Update event of the form try something like this:

Dim dteCurrentTime As Date
dteCurrentTime = Time
If dteCurrentTime >= #4:00:00 AM# And dteCurrentTime < #10:30:00 PM# Then
'Do Nothing
ElseIf dteCurrentTime >= #10:30:00 PM# Then
txtField2 = DateAdd("d", 1, txtField2)
Else
MsgBox "What are you doing here at " & Time & "?", vbOKOnly + vbExclamation
End If
 
M

Marshall Barton

Antonio said:
Is there an expression that can be used to change the
current date of a "date" field to the following days date
after a specific hour of time? If no expression, can some
sort of code be written to do the job?

Example:
All entries between 04:00AM and 10:29 PM = Date()
All entries 10:30 PM and 11:59 PM = Date()+1

I think this will do that:

dtfield - (DateDiff("n", CLng(dtfield), dtfield )>=22.5*60)
 

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