View Full Version : Time in access


bluegoldfish
11-10-2004, 07:35 AM
Hey, this is my first time on this forum, and i was genrally just looking for help. Im an A-Level student venturing into unknown territory and need a few questions being answered!

Im doing a squash and badminton booking system for a local leisure centre i am having trouble adding time into my database in relation to bookings, any ideas how it is possible to use time to complete this project because its annoying! cheers,

bluegoldfish

ColinEssex
11-10-2004, 07:47 AM
Set the field data type to "Date/Time" and the format to short time. Then just type it in.

Col

The_Doc_Man
11-10-2004, 07:48 AM
Time is tricky because even though it seems to be an absolute thing, it is not. Time in Access is RELATIVE to a system reference date and time. Usually this date is Midnight 1-Jan-1900, but I'm told some exceptions exist.

Time is stored as a DOUBLE (floating) time interval between the reference date/time and the object date/time. Units = days. Times are represented as decimal fractions of a day. Which means that one second = 1/86400 in the fractional part of the number. As a DOUBLE, this number has enough range to support any date since 1900 through something past 2100 easily. Actually, more than this, but I think 2100 is the first year where the most common date conversion algorithms start breaking down.

Anyway, the reason you have trouble with time is that if you have a time without a date, it isn't without a date once you store it in a date/time field. It becomes a time ON THE REFERENCE DATE! So conversion becomes nearly impossible without some gyrations. (Excel does this too!) It is not totally impossible to manage, but if you don't expect this behavior, it tosses you for a wild ride.

You MIGHT do better to somehow generate a reference table of time slots, pre-tagged (by hand if necessary) that you can use to populate your bookings table with an appropriate append that adds slots with ordinary system dates but manually tagged time slots.

To generate the date, look at the Help file for the DatePart and DateAdd functions, which give you ways to manipulate date information. Also DateSubtract. Also you might wish to examine User-formatted Time using the Format function on a date field.

bluegoldfish
11-10-2004, 08:55 AM
Thank you for your help, no doubt i will be back for help soon!!!

cheers

rob