Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

difference between two date fields

Hi I have 2 date fields, Month_Code and start date.

Now i need to get the difference between two dates and the desired one should be in months. I need to do in script

Can you please tell me how to do it.

Thanks,

Bharat

1 Solution
6 Replies
vvira1316
Specialist II
Specialist II

Hi Bharat,

Have you tried interval function, or you can use Num and date functions depending on formats. Any sample data may help to understand your particular situation and come up with a solution.

BR,

Vijay

bharatkishore
Creator III
Creator III
Author

Hi Vijay,

In my script i have the below one:

load Equipment,

      System_Code,

      Calendar_Month_Code,

      Contract,

      Warranty,

      Installation,

      UnResolved,

      [T&M],

      [Part Group],

      Key_EMS,

      Install_Flag ,

      Removal_Flag ,

Technical_Start_Date,

Technical_Start_Date - Calendar_Month_Code as Age (while subtracting i need to get output in number months ) (Need to derive this new field)


Please let me know if you need anything more.


T.PNG


image for reference.


Thanks,

Bharat


bharatkishore
Creator III
Creator III
Author

stalwar1‌.. Sunny Bhai can you please have a look..

bharatkishore
Creator III
Creator III
Author

thank you...

vvira1316
Specialist II
Specialist II

datatable:
LOAD * Inline
['Calendar_Month_Code', 'Technical_Start_Date'
'2010-02', '2000-09']
;

ProcessedTable:
LOAD
Date#(Right([Calendar_Month_Code],2) & '/01/' & Left([Calendar_Month_Code], 4), 'MM/DD/YYYY') as [Calendar_Month_Code],
Date#(Right([Technical_Start_Date],2) & '/01/' & Left([Technical_Start_Date], 4), 'MM/DD/YYYY') as [Technical_Start_Date],
Num(Date#(Right([Calendar_Month_Code],2) & '/01/' & Left([Calendar_Month_Code], 4), 'MM/DD/YYYY')) as CMCNum,
Num(Date#(Right([Technical_Start_Date],2) & '/01/' & Left([Technical_Start_Date], 4), 'MM/DD/YYYY')) as TSDNum,
Date#(Right([Calendar_Month_Code],2) & '/01/' & Left([Calendar_Month_Code], 4), 'MM/DD/YYYY') -
Date#(Right([Technical_Start_Date],2) & '/01/' & Left([Technical_Start_Date], 4), 'MM/DD/YYYY') as Age
Resident datatable;

DROP Table datatable;




ss5.PNG