From: Rick James Date: June 20 2012 5:22pm Subject: RE: Need Query Help List-Archive: http://lists.mysql.com/mysql/227709 Message-Id: <2E7DD7ADE53B044C8C8BCD9C5829E1EB1487608195@SP2-EX07VS01.ds.corp.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#functio= n_timediff and SEC_TO_TIME()/3600 > -----Original Message----- > From: Anupam Karmarkar [mailto:sb_akarmarkar@stripped] > Sent: Wednesday, June 20, 2012 2:39 AM > To: mysql@stripped > Subject: Need Query Help >=20 > Hi All, >=20 > I need query help for following table struture, where we need to > calculate login duration of that employee for give period. >=20 > Example table >=20 >=20 > EmployeeID =A0=A0=A0 LoginTime=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0LogoutTIme >=20 > 101=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 2012-05-01 10:00:00=A0 =A0= =A0 2012-05-01 12:30:00 > 102=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 2012-04-31 23:00:00=A0=A0= =A0 =A0 2012-05-02 05:00:00 >=20 > 103=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 2012-05-01 14:00:00=A0=A0= =A0=A0=A0 NULL > 104=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 2012-05-02 00:10:00=A0=A0= =A0=A0=A0 2012-05-02 05:00:00 >=20 >=20 > I tried to fit all scenario in above table, Consider NULL as yet to > logout >=20 >=20 > How would i calcuate Employee and it Login duration for period say from > 2012-05-01 08:00:00 to 2012-05-01 22:00:00 >=20 >=20 > --Anupam