sql - date time difference get hour:minutes:seconds -


i have query this:

select t.paydate,t.deldate,datediff(mi, t.paydate,t.deldate) datdiffernce  transaction_tbl t  t.transactid=19 

i getting out put this:

paydate                 deldate                 datdiffernce ----------------------- ----------------------- ------------ 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000     22 

datedifference getting 22 mints.

instead of getting how can date difference in format hh:mm:ss?

try this,

select convert(varchar(10),datediff(hour,t.paydate,t.deldate))+'hr:'        +convert(varchar(10),datediff(minute,t.paydate,t.deldate)% 60) + 'mnts:'        +convert(varchar(10),datediff(second,t.paydate,t.deldate)% 60) +'seconds'        'diff in hh:mm:ss' transaction_tbl t  t.transactid=19   

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -