Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
manu1512
Creator
Creator

Number of days in Month and days

Hi all,

 I have a expression where i am finding remaining days  with exression 

 

contractlineenddate - today().

 

But i want to display no of days as months and days

 

like 95 days becomes  3 months 5 days.

 

Can someone pls help me?

 

Kind Regards

Manu

1 Reply
NW1965
Creator
Creator

I'm going to assume that you don't simply mean (95/30) to show months and then take the remainder as days, that you want to recognise that one of those months is 30 days and the other two might be 31.

This being the case, this syntax in your load script works and produces two fields, a Difference in Months and a Difference in Days.

You can add this as a preceding load to your table if you like.

IF(Day(ContractEndDate)>=Day(CurrentDate)
,((
Year(ContractEndDate)*12)+Month(ContractEndDate)) - ((Year(CurrentDate)*12)+Month(CurrentDate))
,
IF(Day(ContractEndDate)<Day(CurrentDate)
,(((
Year(ContractEndDate)*12)+Month(ContractEndDate)) - ((Year(CurrentDate)*12)+Month(CurrentDate))) - 1
))
AS Difference_NumberOfMonths


IF(Day(ContractEndDate)>=Day(CurrentDate)
,
Day(ContractEndDate) - Day(CurrentDate)
,
IF(Day(ContractEndDate)<Day(CurrentDate)
,
Day(MonthEnd(CurrentDate)) - Day(CurrentDate) + Day(ContractEndDate)
))
AS Difference_NumberOfDays