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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subtracting dates; Today() from previous date

Hello,

How do i subtract Today from a previous date format 'D/MMM/YYYY' so i get my answer in the underline format below

SCENARIO:

Today() - December 1st 2000 = "14 years, and 27 days"

Rgds

7 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

=If(Interval(Today()  -  MakeDate(2000,12,1), 'DD') >= 365,

Div(Num(Interval(Today()  -  MakeDate(2000,12,1), 'DD')), 365) & ' Years, ', '')

&

If(Mod(Interval(Today()  -  MakeDate(2000,12,1), 'DD'), 365) > 0,

Mod(Interval(Today()  -  MakeDate(2000,12,1), 'DD'), 365) & ' Days', '')

Regards,

Jagan.

Not applicable
Author

What i have there is just a senario, It can also return number of Year, Month and Day. Its too  static

I mean somthing like this:

Today - "D/MMM/YYYY" = Number of Year, Number of Month and Number of Days

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

=Age(Today(), MakeDate(1999,11,30)) & ' Years, ' & Mod(Num(((year(Today()) * 12) + month(Today())) - (((year(MakeDate(1999,11,30)) * 12) + month(MakeDate(1999,11,30))))), 12) & ' Months, '

& Fabs(Day(Today()) -  Day(MakeDate(1999,11,30))) & ' Days'

Regards,

Jagan.

Not applicable
Author

Hello,

Please use this, the previous code didnt work. This will be more clearer.

Note: Use Employ Date

Thanks

Anonymous
Not applicable
Author

Hi Try the below code

=If(Today()-Date(MakeDate(2000,12,1),'DD/MM/YYYY') >=365,Round(Num(Today()-Date(MakeDate(2000,12,1),'DD/MM/YYYY')) / 365) & ' Years ' &
If(Today()-Date(MakeDate(2000,12,1),'DD/MM/YYYY') >=365,Date(Today()-MakeDate(2000,12,1),'DD')) & '  Days')


Not applicable
Author

Hello V

Find attached plz

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try this script

TableName:

LOAD
*,
Age(Today(), Date_Employed) & ' Years, ' & Mod(Num(((year(Today()) * 12) + month(Today())) - (((year(Date_Employed) * 12) + month(Date_Employed)))), 12) & ' Months, '
&
Fabs(Day(Today()) - Day(Date_Employed)) & ' Days' AS Formatted_Date;
LOAD [S/N],
[Date of birth],
date([Date Employed]) as Date_Employed,
Sex
FROM

(
qvd);

Now use Only(Date_Employed) AS Expression in your chart.

Regards,

jagan.