Skip to main content

Hi Team,

 

I need your help to find the date difference between two dates and result should shown as year and months in one column

 

for example. i have date of joining 27-10-2018 and today date 28-05-2020

 

i need the answer as 1 year 7 months

 

i have used datediff('year','27-10-2018','28-05-2020') and i got a result as 1.5863.

 

Please advise

3 answers
  1. May 28, 2020, 12:03 PM

    well it sounds like you are close

     

    I would use months in the date diff  as in    datediff('month','27-10-2018','28-05-2020')

    .

     

    yrs =  int( (    datediff('month','27-10-2018','28-05-2020'))/12)

     

    months = int(( (    datediff('month','27-10-2018','28-05-2020'))% 12)  * 12)

     

    and then put them together in       str(yrs) + +' Years  and  ' + str(months) +' Months'

     

    you may need to play with syntax  a little

     

    Jim

    If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

0/9000