Thread: Access Help
View Single Post
Old 06-10-2003, 07:30 AM   #7 (permalink)
rubicon
Stop. Think. Question.
 
rubicon's Avatar
 
Location: Redondo Beach, CA
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..
rubicon is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73