Calculate Days months Years between two dates

Stimulsoft Reports.WEB discussion
Post Reply
omkar.patange
Posts: 22
Joined: Wed Dec 05, 2018 12:01 am

Calculate Days months Years between two dates

Post by omkar.patange »

calculate Days months between two dates.
For Eg: Start Hiring Date: 1 Jan 2020 To Today (5 March 2021)
What expression should I Use to get a result? I need an expression for Years/Months and Days.

1 year, 2 months, 4 days

I can use separate columns (expression) for each Year, Months, and Days.

I have already followed precious expressions: 1. (Startdate-Today).TotalDays 2. DateDiff(Startdate,today).Days

Not getting Correct result. Please Help!
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Calculate Days months Years between two dates

Post by Lech Kulikowski »

Hello,

You can use the following expression:
{(DateTime2 - DateTime1).Days}

And then calculate years, months, and days separately as you need.

Thanky ou.
bojef
Posts: 1
Joined: Tue Feb 07, 2023 1:10 pm

Re: Calculate Days months Years between two dates

Post by bojef »

Hello all. I’ve been searching for a solution to get the difference between two dates in years, months and days like 10th of April 2021 was 2 years, 2 months and 11 days ago, or 12th of Juli 2023 was 0 years, 2 months and 12 days ago. (in reference to current date 24/9/21).

I know how to get the amount of years incontagem ferias, this should be done by calanderYearsBetween(Date1, CurrentDate), the amount of monts should be something like calanderMonths(Date1, CurrentDate) – (12 * amountOfYears). But I can’t think of something to get the amount of days.

Is there any option to calcualte something like this, it needs to be exact...
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Calculate Days months Years between two dates

Post by Lech Kulikowski »

Hello,

Please try to check the following solution:
https://stackoverflow.com/questions/382 ... in-c-sharp

Thank you.
Attachments
Screenshot 2023-02-09 093752.png
Screenshot 2023-02-09 093752.png (83.26 KiB) Viewed 1014 times
DateDiff-YearMonthDays.mrt
(10.1 KiB) Downloaded 74 times
Post Reply