I've never really had a use for time that didn't also use date as well.
In your case, what would happen if an employee's shift overlapped
midnight?  For example, the person starts at 9:00 pm and quits at 5:00
am.  If you disregard the date, wouldn't you end up with a negative
time?


If this doesn't matter, I would just use a numeric field and store the
number of seconds since midnight for both the start and end of the
shift.  That way, simple math would give you the number of seconds of
actual work time.


M!ke

________________________________

From: Richard Meredith-Hardy [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 19, 2004 8:30 AM
To: CF-Talk
Subject: time conumdrum

Dear all

In converting over a timesheets application from Access to MSSQL I am
having difficulty with datetime fields:  consider the following (in
CF5):

<CFSET t1 = createtime("00","00","00")>
output: {ts '1899-12-30 00:00:00'}
<CFSET t2 = createtime("12","00","00")>
output: {ts '1899-12-30 12:00:00'}
<CFSET t3 = createtime("00","30","00")>
output: {ts '1899-12-30 00:30:00'}
<CFSET t4 = t1 + t2>
output: 0.5
<CFSET t4a = t2 + t3>
output: 0.520833333333
<CFSET t4b = createodbctime(t2 + t3)>
output: {t '12:30:00'}
<CFSET t4c = createodbcdatetime(t2 + t3)>
output: {ts '1899-12-30 12:30:00'}

The values above are all saved to a MSSQL DB in datetime fields, this is
the output:

t1: 1899-12-30 00:00:00
t2: 1899-12-30 12:00:00
t3: 1899-12-30 00:30:00
t4: 1900-01-01 12:00:00
t4a: 1900-01-01 12:29:59
t4b: 2004-09-19 12:30:00
t4c: 1899-12-30 12:30:00

As you can see, there are various inconsistencies here which will make
further calculations dangerous and/or tricky (summaries etc) and also
might produce different results if / when we upgrade CF.

In fact all I am interested in are the hh:mm, I was wondering what other
people do when recording and calculating time...  

Thanks

--
Regards;

Richard Meredith-Hardy
-------------------------------------------------------------
r[dot]mh[at]flymicro[dot]com
Tel: + 44 (0)1462 834776 FAX: + 44 (0)1462 732668
________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to