Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Script to subtract time between 2 columns

Hi, how do I find the difference in time between 2 columns 'Date Created' and 'Date Confirmed' and display the difference in mins? Thanks.

11 Replies

Re: Script to subtract time between 2 columns

Hi,

Try below

Interval( Date('2010-11-19 09:22:09.000') - Date( '2010-11-19 11:52:38.000'), 'hh:mm:ss')

Interval( Date('19:43') - Date( '12:56'), 'hh:mm:ss')

If you need in minute then try below.

time(frac(date2) - frac(date1))

Regards

ASHFAQ

venkatasreekant
Valued Contributor

Re: Script to subtract time between 2 columns

Try this:

Timestamp#(Timestamp#([Fieldname1])-Timestamp#([Fieldname2]))

nlmmaurya
New Contributor II

Re: Script to subtract time between 2 columns

Hi,

Try this:

Interval(([Date Confirmed]- [Date Created]),'mm:ss')

Regards,

Neelam

crusader_
Valued Contributor

Re: Script to subtract time between 2 columns

Hi,

Try this one:

Interval([Date Confirmed]-[Date Created])

HTH

Andrei

Not applicable

Re: Script to subtract time between 2 columns

I cannot use specific time as I want to find the time difference for all the times between the 2 mentioned fields. Thanks.

Not applicable

Re: Script to subtract time between 2 columns

Thanks, but I got negative minutes until a thousand over for example '-1034'

Not applicable

Re: Script to subtract time between 2 columns

Thanks, but why do I have negative timings now.

crusader_
Valued Contributor

Re: Script to subtract time between 2 columns

Are you sure that [Date Created] less than [Date Confirmed] ?

Cause you shouldn't get negative results

Andrei

Not applicable

Re: Script to subtract time between 2 columns

Hi Rachel,

Can you attach a sample of your data, as in one of my apps I use the below and i have accurate results:

num#(Interval(SESSION_DATEFIN - SESSION_DATEDEB, 'ss')) / 3600 as TimeInHr,

num#(Interval(SESSION_DATEFIN - SESSION_DATEDEB, 'ss')) / 60 as TimeInMin,

num#(Interval(SESSION_DATEFIN - SESSION_DATEDEB, 'ss')) as TimeInSec

Community Browser