Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

calculate date from years of service

I have "years of service" column in my database with value for eg 4.34. How do i calculate the service date?

Logically it should be Date(Today() - "years of service")

But can someone help me write exact expression in load script.

Thanks

2 Replies
Highlighted

I believe something like this should work:

SELECT    Years_of_Service,

          Date(Today()-Years_of_Service*365.25) as Service_Date

FROM YourTable;

You can test it with this:

LOAD Years_of_Service,

     Date(Today()-Years_of_Service*365.25) as Service_Date

INLINE [

Years_of_Service

2.34

4.34

];

Highlighted

please post some sample values and your expecetd result.

It's not quite clear, how the fractional year part is calculated in the first place. There might be different methods (fixed number of days per year vs. considering leap years...)

thanks

regards

Marco