I'm sure this is a simple solution to all you fabulous pros out there, so I am only going to include 2 days of the week in my sample code, rather than the full weeks' days. Alternate solutions/suggestions are appreciated, as I am used to only coding within the queries themselves but would love to expand my knowledge.
Employee Data Table
IN-Mon Date/Time [Format Medium Time]
OUT-Mon Date/Time [Format Medium Time]
LCH-Mon Yes/No
IN-Tue Date/Time [Format Medium Time]
OUT-Tue Date/Time [Format Medium Time]
LCH-Tue Yes/No
You get the idea...
In my first Query (qry_sbfm_DataC alcs1), I am using to following code to determine the number of hours worked each day
This works fine and returns the number values I am looking for. When I look to add these values, however, I am being returned a string value rather than the numeric total.
This returns, 9.59.5 as opposed to 19. I did try reading around the forum and tried CDate, etc unsuccessfully (as in I don't really understand what they do or how to use them...)
Since the WeekTotal will be used in my next calculations I need it to reflect a number of hours, as opposed to the string. Here is the code, so you can see where I'm headed.
As always, I appreciate your time/guidance.
Employee Data Table
IN-Mon Date/Time [Format Medium Time]
OUT-Mon Date/Time [Format Medium Time]
LCH-Mon Yes/No
IN-Tue Date/Time [Format Medium Time]
OUT-Tue Date/Time [Format Medium Time]
LCH-Tue Yes/No
You get the idea...
In my first Query (qry_sbfm_DataC alcs1), I am using to following code to determine the number of hours worked each day
Code:
MonTotal: IIf([LCH-Mon]=-1,((Format((DateDiff("n",[IN-Mon],[OUT-Mon])\60),"Fixed")-0.5)),(Format((DateDiff("n",[IN-Mon],[OUT-Mon])\60),"Fixed"))) TueTotal: IIf([LCH-Tue]=-1,((Format((DateDiff("n",[IN-Tue],[OUT-Tue])\60),"Fixed")-0.5)),(Format((DateDiff("n",[IN-Tue],[OUT-Tue])\60),"Fixed")))
Code:
WeekTotal: [MonTotal]+[TueTotal]
Since the WeekTotal will be used in my next calculations I need it to reflect a number of hours, as opposed to the string. Here is the code, so you can see where I'm headed.
Code:
RegHrs: Format(IIf([WeekTotal]>44,44,[WeekTotal]),"Fixed") OTHrs:Format(([WeekTotal]-[RegHours]),"Fixed")
Comment