Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

date difference in script giving different result than in textbox

Hello,

when I put the below expression in load script, it gives -1.2952808600665e-005. When I put it in a textbox, it gives 3 which is correct

let t = 4/23/2014 - 4/20/2014

actually the above expression coming from difference of two date fields. can someone please guide me how to fix this

Arif

2 Replies
maxgro
MVP
MVP

if you have 2 dates, the difference is (bold)

src:

load

  date(today() + rowno()) as d1,

  date(today() + 2*rowno()) as d2

autogenerate 100;

fin:

load

  d1,

  d2,

  d2 -d1 as datediff

resident src;

if you have 2 constant dates (I use your format) the difference is

=date#('4/23/2014','MM/DD/YYYY')  - date#('4/20/2014', 'MM/DD/YYYY')

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Data:

LOAD

*,

  date(Date1)  - date(Date2) As Difference

FROM DataSource;


You need to format the date.


Regards,

Jagan.