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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jjustingkm
Creator II
Creator II

Issue with interval function field export to excel

I have a field with interval function like below. When i export to excel, it comes with a suffix AM/PM. 

 

Interval(END_DT-BEGIN_DT, 'hh:mm:ss')

field

8:00:00 PM

 

Labels (1)
3 Replies
sbaro_bd
Creator III
Creator III

See the default format on your main script. If i'm not wrong, you got something like this (see the attached file).

Change the time format in your script from "SET TimeFormat='h:mm:ss TT';" to this "SET TimeFormat='hh:mm:ss';".

 

jjustingkm
Creator II
Creator II
Author

Thanks for you reply

I have made the change as you mentioned but still getting the same issue while exporting to excel.

jjustingkm_0-1734709952432.png

 

 

SET TimeFormat='hh:mm:ss'
SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';

Qrishna
Master
Master

Dont Change Any key Variables in qlik script. The Culprit is Excel, not on the Qlik Side.

This issue occurs because Excel treats hh:mm:ss as a time and formats it as a timestamp hence adds an "AM/PM" suffix.
To address this, you need to export the duration in a text format so Excel does not interpret it as a time value.

if you dont wrap it in Text() , i.e if you use something like below, it will formatted by excel.
Interval(END_DT - BEGIN_DT, 'hh:mm:ss')) AS Duration:

2498595 - Issue-with-interval-function-field-export-to-excel (1).PNG


if you wrap it in Text() , In this format, Excel will display the duration as-is, without interpreting it as a time.
Text(Interval(END_DT - BEGIN_DT, 'hh:mm:ss')) AS DurationAsText:

2498595 - Issue-with-interval-function-field-export-to-excel (2).PNG


The Text() function ensures the Interval() output is treated as plain text, preventing Excel from reformatting it as a time value.