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

Duration issue in Time Field

Status
Not open for further replies.

balderdash

Programmer
Mar 9, 2004
5
GB
Dear All,

I currently have a field that shows the number of minutes an event has happened. I wish to store this in a time field. This in itself is not a problem, however, the number of minutes within my data can be greater than 24 hours. Access will not accept a value greater than 23:59:59 in a time field. Is there anyway that anyone is aware of that I can override this?

I dont wish to format a text field as I would like to be able to run calculations on this field once formatted.

Many thanks

Balderdash
 
you need a date field/value...

a full date/time field is in the format:

dateserial.timeserial

 
balderdash,

Realize that Date/Time VALUES are NUMBERS, like right now is 38218.36915 which can be formatted in any number of ways using the FORMAT function.

So 25 hours would be
[tt]
25/24 or 1.04166667
[/tt]
Hence Crowley16's suggestion.



Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Date/Time data types are (in my view) to be used for storing points in time (eg Date and Time of Birth)

If you want to store elapsed time, just store it is a straightforward long data type and store the elapsed time in the appropriate units (eg minutes in your case)

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I agree with Ken.

The only caveat might be that if you wanted to ADD Duration to a Date/Time value, you would then need to CONVERT Minutes to Days.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Hi

Thanks for agreeing skip

but..

if you use DataAdd() you can add just about any time units you want, so it matters little if your elapsed time is in minutes, hours, days, months, years. My point is it is just a number, in the same way that (say) 10 pounds or 10 dollars is just a number (as far as the computer is concerned). Date/time has this added complication that we present it as days, months etc and it uses various factors (eg 60 seconds in a minute etc) but by storing elapsed time as a number in the appropriate units for the application we can simplify all of that and simply present the results in the appropriate human readable form. Access/VBA provides the tools to handle all of this (eg DataAdd(), Format() etc)

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
You are so right about DateAdd. I hardly ever use. I automatically think in terms of units conversion.

What a dinosaur I am.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top