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

Time Clock Report - Query Help 1

Status
Not open for further replies.

johnhig

MIS
Jun 25, 2007
54
US
Good Morning -

I am having a problem with my query. I have a little timeclock table. I just want to output my data to a time clock report which display all time clock activity from yesterday.

So I created my query like the following:

SELECT Username, TimeIn, TimeOut, Status, DATEDIFF(hh, TimeIn, TimeOut) AS TotalHours, DATEDIFF(n, TimeIn, TimeOut) AS Totalminutes
FROM Clock2
WHERE timein = #CreateODBCDate(DateAdd("d", -1, Now()))#
GROUP BY ID, Username, TimeIn, TimeOut, Status
ORDER BY Username


When I generate my report. No data appears.

If I do change my WHERE clause to <= of course I get all prior data...where I just want yesterday.

What am I doing wrong?

Thanks John
 
Your query must consider the time as well as the date

Code:
WHERE     timein >= #CreateODBCDate(DateAdd("d", -1, Now()))#
AND       timein < #CreateODBCDate(Now())#
 
One more question....Is there a reason why my minutes would be off?

When I run the query through query analyzer it pulls the correct data.

Then I run the .cfm page and it calls a template from the Report Builder (same query runs and on the .cfm page)

The Report Builder delivers the report and the hours are correct but the minutes are off.

For Example the sql table will say 7:06, but the report is display 7:10.

The time is correct on the servers. Not sure what I am doing wrong.

John
 
Got it. It was all in my formatting.

I ended up using the LSTimeFormat and it works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top