Print Page | Close Window

Calculate Years, Months & Days between two dates

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14260
Printed Date: 03 May 2024 at 5:21am


Topic: Calculate Years, Months & Days between two dates
Posted By: Kitty1
Subject: Calculate Years, Months & Days between two dates
Date Posted: 02 Sep 2011 at 4:29am

Hello,

I need to calculate in years, months and days - the difference between employees Hire Date and today's date.   Any ideas how to do this ?

Thanks!  :)




Replies:
Posted By: saqibmsd
Date Posted: 04 Sep 2011 at 12:30am
numbervar a := (LeavingDate-HiringDate);
numbervar b := a mod 365;
numbervar c := b mod 30;

ToText(Truncate(a/365),0) +" yr(s) "+ ToText(Truncate(b/30),0) +" mth(s) "+ ToText(c,0) +" day(s)";

-------------
Share and Spread


Posted By: Kitty1
Date Posted: 06 Sep 2011 at 11:03am
thank you so very much!  it worked perfectly!!!  :-)



Print Page | Close Window