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

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

Working with dates and auto increment

floor((Today() - Date([Date],'D-MMM-YYYY'))/365) &' Years, ' &  floor(Frac((Today() - Date([Date],'D-MMM-YYYY'))/365)*12) &' Months, '& num(frac(Frac((Today() - Date([Date],'D-MMM-YYYY'))/365)*12)*30,'#,##0') & ' Days'  as [Date spent]

Hello,

Check this code segment. Am calculating subtraction of a date from present date; Year, Month and Day But there is a problem dealing with Leap-Year, and Months having up to 31 days. How do i resolve this? Check code segment very well.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps like this:

Year(Today()) - Year( [Date]) + (DayNumberOfYear(Today())<DayNumberOfYear([Date])) & ' Years' &

Month(Today()) - Month( [Date]) - 12 * (DayNumberOfYear(Today())<DayNumberOfYear([Date])) & ' Months' &

Day(Today()) - Day([Date]) - Day(MonthEnd([Date])) * (Day(Today())<Day([Date])) & ' Days' AS [Date Spent]


talk is cheap, supply exceeds demand
Not applicable
Author

I implemented, attached didnt give what i wanted to achieve. [Date spent1] field worked but need to resolve the issues mention above. Find attached

Regards

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw.


talk is cheap, supply exceeds demand