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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging separate Date & Time fields as single Date-Time field

Status
Not open for further replies.

Locoman

Technical User
Sep 25, 2002
38
0
0
GB
Hi folks,

I searched through loads of posts about Date arithmetic etc. but can't quite find a situation like I have:

I work with an old database which has separate pairs of fields, StartDate and StartTime, and EndDate End Time.

I need to calculate (in minutes) the elapsed time between start and end, but to keep the query simple I would like to find a way without doing this in separate difference stages for days then time.

I could do this with DateDiff function in one go if the start and end were single date-time fields rather than two separate ones. Is it possible somehow to combine each pair of fields retrospectively into one?

Thanks in advance
 



Hi,
Code:
ElapsedMin = ([EndData]+[EndTime]-([StartDate]+[StartTime]))*24*60


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks Skip - I did not realise you could actually add times to dates directly unless the field was set to the "general" date/time format. After experimenting with your solution it seems that both Date and Time variables have implicit components of each other, even if they are not always visible. Isn't Access wonderful!
 



It's really NOT an Access thing. Date and Time are part of the same thing. Date/Time VALUES are just NUMBERS, like right now in Texas, the Date/Time VALUE is 39220.31286 - 39,220 days since 1/0/1900 and .31286 of today has transpired.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top