Try this:
Private Sub DateSub()
' declare variables
Dim intHourCurrent As Integer
Dim blnHourValid As Boolean
Dim strYourDate As String
' fetch current hour
intHourCurrent = DatePart("h", Now)
' if hour is between 00:00 and 17:00 then set flag to true, else false
blnHourValid = IIf((intHourCurrent >= 0 And intHourCurrent <= 17), True, False)
' if flag is true, store the previous day's date, else the current date
strYourDate = IIf(blnHourValid, Date - 1, Date)
' display results
MsgBox ("blnHourValid = " & blnHourValid & ", strYourDate = " & strYourDate)
End Sub
EDIT: I used the current time on my PC clock which was 8:30 am. I didn't change the clock to test the FALSE condition.
__________________
How you do anything is how you do everything.
Last edited by rubicon; 06-10-2003 at 07:35 AM..
|