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

SQL to convert eAgentLoginStat.Timestamp to Date only

Status
Not open for further replies.

rmscho02

Technical User
Jan 14, 2011
18
US
I'm querying the eAgentLoginStat table and need help with the SQL. I want to get the shift duration for each agent per day, so I need to do a group by Timestamp and AgentID in the query. the problem is the timestamp doesn't group by day because it has the time in it. How can I convert the timestamp to just the date within the SQL? Do I use something like CAST or CONVERT (neither of which I'm sure how to use).

Thanks!
 
The eAgentLoginStat table logs all events with timestamp, for this I use the dAgentPerformanceStat.LoggedInTime table.

I use the following formula (in Crystal Reports) to convert to a date: Date({dAgentPerformanceStat.Timestamp})

For calculating a shift duration I also use the formulas:
FirstLoginMIN = Minimum({eAgentLoginStat.Time},{eAgentLoginStat.UserID})
LastLogoutMAX = Maximum({eAgentLoginStat.Time},{eAgentLoginStat.UserID})

Here a copy of the SQL query, hope this helps;
SELECT eAgentLoginStat.Timestamp, eAgentLoginStat.UserID, eAgentLoginStat.Time
FROM blue.dbo.eAgentLoginStat eAgentLoginStat
WHERE eAgentLoginStat.UserID=0x



 
If you just need LoggedInTime have you thought about querying the dAgentPerformanceStat as there is a LoggedInTime column in that table. The benefit of using the dAgentPerformanceStat table is that shifts that last past midnight are broken into the two different days. So you don't end up with a LoggedIn and no LoggedOut event for the day.
 
I need the entire shift duration, which from what I can tell is more than just the LoggedInTime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top