Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Field based on Date/Time range

Status
Not open for further replies.

tubbers

Technical User
Jun 23, 2004
198
US
I'm pretty sure this is something easy to do but I'm kind of fuzzy on how to get this started...

I have a field called LastDetect, which is in date/time format, like this:

Code:
[b]LastDetect[/b]
2/15/2004 00:20:20 PM
5/1/2004 1:20:00 AM
5/1/2004 1:59:59 AM
5/1/2004 2:00:03 AM

I need to have a new field which which return a hour value if the LastDetect value falls within a specific range, like this:

Code:
[b]LastDetect         Hour[/b]
5/1/2004 1:20:00 AM   0100
5/1/2004 1:59:59 AM   0100
5/1/2004 2:00:03 AM   0200
5/1/2004 2:00:03 PM   1400

(Hope that made sense)
Basically, if LastDetect value is occurs at any time in the 0100 hour, the Hour would be 0100 regardless of whether the LastDetect was at 0100 or 0159.

I have a feeling this is an easy thing but not sure how to get started.

Any suggestions?
 
Hi

[tt]
hr = Hour(MyField)
[/tt]


Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Great, that totally worked out for me!

Is there a way to format the results? Right now the results are 17 or 1, I would like 1700 and 0100 if possible.

Thanks for your help.
 
Just multiply by 100.

OR
[tt]
strHour = Format(MyField, "hh") & "00"
[/tt]

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top