Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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

Accepted Solutions
Highlighted
Specialist II
Specialist II

Re: difference between two date fields

6 Replies
Highlighted
Specialist II
Specialist II

Re: difference between two date fields

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

Highlighted
Creator III
Creator III

Re: difference between two date fields

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


Highlighted
Creator III
Creator III

Re: difference between two date fields

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

Highlighted
Specialist II
Specialist II

Re: difference between two date fields

Highlighted
Creator III
Creator III

Re: difference between two date fields

thank you...

Highlighted
Specialist II
Specialist II

Re: difference between two date fields

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