Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   Access Help (https://thetfp.com/tfp/tilted-technology/9827-access-help.html)

Kent Brockman 06-03-2003 03:48 AM

Access Help
 
I working on a program that will take into account the time of day before determining the date. I know it will take an If, Then statement (I think), but all I can think of is

If [Time] between 12:00:00 AM and 05:00:00 PM then [Date] = Date()-1

Hopefully that will make sense somehow. That code does not work obviously, I just don't know what to do. Any help would be appreciated.

rubicon 06-03-2003 07:46 AM

What are you trying to accomplish?

You can call the function

Date() - 1

and it will subtract one day from the current day. Likewise,

Date() - 30

is 30 days earlier than the current date.

Kent Brockman 06-03-2003 10:57 AM

I do need the day to be one previous, but it depends on the time of day. If the entry is made between 12:00 AM and 5:00 PM, it needs to be the previous days date, if not the current day would be used.

rubicon 06-09-2003 04:33 PM

Do you still need help on this?

Kent Brockman 06-10-2003 04:30 AM

Yes, sorry about the delay

Brewmaniac 06-10-2003 04:51 AM

Quote:

Originally posted by rubicon
Hell - the absence of broadband.
You've got that right! I'm stuck in dial-up hell!

rubicon 06-10-2003 07:30 AM

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.


All times are GMT -8. The time now is 10:02 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


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