Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Difference Between two date_time fields?

Hi I ahve 2 date time fields I want get difference beetween two times ..

How can i can get difference ...

my code is:

Directory;

Master:
LOAD callid,calldata as Call_Details
FROM

[qvd];
directory;
Call_Details:
LOAD TextBetween(Call_Details,'<CALLID>','</CALLID>') as "CALL ID",TextBetween(Call_Details,'<STARTDATETIME>','</STARTDATETIME>') as "START DATE",TextBetween(Call_Details,'<ENDDATETIME>','</ENDDATETIME>') as "END DATE" resident Master;
DROP Table Master;


Calc_Diff:
LOAD [CALL ID],[START DATE],[END DATE],(Timestamp([END DATE],'MM-DD-YYYY HH:mm:SS TT')-Timestamp([START DATE],'MM-DD-YYYY HH:mm:SS TT')) as 'DURATION' Resident Call_Details;
DROP Table Call_Details;

i followed this code but when i try to display duration in listbox it does not show data...

please help me anyone.

27 Replies
MarcoWedel

Hi,

one possible solution:

QlikCommunity_Thread_132311_Pic1.JPG.jpg

Call_Details:

LOAD *,

    Interval([END DATE]-[START DATE], 'hh:mm:ss') as DURATION;

LOAD TextBetween(@1,'<CALLID>','</CALLID>') as [CALL ID],

    Timestamp(Timestamp#(TextBetween(@1,'<STARTDATETIME>','</STARTDATETIME>'), 'YYYY-MM-DD hh:mm:ss.fff'),'DD/MM/YYYY hh:mm:ss') as [START DATE],

    Timestamp(Timestamp#(TextBetween(@1,'<ENDDATETIME>','</ENDDATETIME>'), 'YYYY-MM-DD hh:mm:ss.fff'),'DD/MM/YYYY hh:mm:ss')  as [END DATE]

FROM [http://community.qlik.com/servlet/JiveServlet/download/603856-123860/example.csv.xls] (txt, utf8, no labels, delimiter is '\t', msq);

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Hi i dont have lisenced version of Qlikview  can you please give the edit script code........

MarcoWedel

paste this into your personal edition's script editor:

Call_Details:

LOAD *,

     Interval([END DATE]-[START DATE], 'hh:mm:ss') as DURATION;

LOAD TextBetween(@1,'<CALLID>','</CALLID>') as [CALL ID],

     Timestamp(Timestamp#(TextBetween(@1,'<STARTDATETIME>','</STARTDATETIME>'), 'YYYY-MM-DD hh:mm:ss.fff'),'DD/MM/YYYY hh:mm:ss') as [START DATE],

     Timestamp(Timestamp#(TextBetween(@1,'<ENDDATETIME>','</ENDDATETIME>'), 'YYYY-MM-DD hh:mm:ss.fff'),'DD/MM/YYYY hh:mm:ss')  as [END DATE]

FROM [http://community.qlik.com/servlet/JiveServlet/download/603856-123860/example.csv.xls] (txt, utf8, no labels, delimiter is '\t', msq);

and reload.

regards

Marco

PrashantSangle

Hi,

Try with this,

Timestamp(Timestamp#([END DATE],'YYYY-DD-MM hh:mm:ss.fff'))-Timestamp(Timestamp#([START DATE],'YYYY-DD-MM hh:mm:ss.fff')) as Duration

OR

use above field in

Interval(Timestamp(Timestamp#([END DATE],'YYYY-DD-MM hh:mm:ss.fff'))-Timestamp(Timestamp#([START DATE],'YYYY-DD-MM hh:mm:ss.fff')),Format Code)

Date and Time Format must be YYYY-DD-MM hh:mm:ss.fff

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

hi ...

  when i try to load start date in listbox it does nt show any data.

Timestamp(Timestamp#(TextBetween(@1,'<STARTDATETIME>','</STARTDATETIME>'), 'YYYY-MM-DD hh:mm:ss.fff'),'DD/MM/YYYY hh:mm:ss') as [START DATE],

Anonymous
Not applicable
Author

Hi...

Thank you for your reply.....

Its helpfull for me..............

Not applicable
Author

Thank you Marco...

MarcoWedel

You're welcome

Regards

Marco