You don't simply store DATETIME() at the time of punch in and punch out?
Then it would simply be (punch out datetime - punchin datetime). So it's essential you store datetime and not a string of the type you show.
Or does this data come from another system?
If you can't store datetimes to start with, you have to use CTOT() to convert a string to datetime. The format has to be, what the inverse TTOC() outputs, but be aware this depends on your date settings, of which there are quite a bunch:
1. SET CENTURY ON/OFF for two or 4 digit year
2. SET DATE AMERICAN/ANSI/BRITISH/FRENCH/... etc a language specific setting The easiest, if your country is missing: SET DATE TO DMY/MDY or whatever combination of D M and Y.
so for example you do: SET DATE DMY
3. SET MARK TO char for the seperator between month, day, year
so for example you do: SET MARK TO '/'
4. SET HOURS TO 12/24, to set the time portion from 0..23 or from 1 to 12 AM/PM
so for example you do: SET HOURS 24
In one go:
Code:
SET CENTURY ON
SET DATE DMY
SET MARK TO '/'
SET HOURS TO 24
? CTOT("14/04/2013 23:00:00")
? CTOT("14/04/2013 07:00:00")
? CTOT("14/04/2013 23:00:00")-CTOT("14/04/2013 07:00:00")," seconds."
? (CTOT("14/04/2013 23:00:00")-CTOT("14/04/2013 07:00:00"))/3600, " hours."
Now you only have to format your time and date into this format, replace all . with : in you time portion, for example.
You can compute diff in hours by diffs in seconds /3600 (60*60 seconds is one hour).
It's much easier to begin with DATETIME values, so if you have that under your control, then do that.
Bye, Olaf.