Add day to current day.

  • Thread starter Thread starter Antonio
  • Start date Start date
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.
 
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
 
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)
 
Back
Top