sverkot Posted June 20, 2007 Share Posted June 20, 2007 Hi,I want to know if there's a way to get the first and last records from a table.I'm using SQL server 2000 database.My question follows :SELECT createdate from TABLE WHERE agent_name = "JohnDoe" AND createDATE >='start_date' AND createdate <='end_date'This query will fetch me all the createdates for this agent like this. 2007-06-19 13:20:282007-06-19 13:59:56............................................................2007-06-19 23:56:482007-06-19 23:58:29My idea is to use the DateDiff function of vbscript to find the minutes between the first createdate and the last create so I can calculate how many hours this person worked. Is there a way to get the first and last record from the result of this query? Thanks,Sang. Link to comment Share on other sites More sharing options...
aalbetski Posted June 21, 2007 Share Posted June 21, 2007 this may work SELECT max(createdate)from TABLE unionSELECT min(createdate)from TABLE WHERE agent_name = "JohnDoe" AND createDATE >='start_date' AND createdate <='end_date' Link to comment Share on other sites More sharing options...
sverkot Posted June 21, 2007 Author Share Posted June 21, 2007 That's what I did and looks like it's working. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.