How to get the difference in Date ,years, Month based on current date

I need to get the Difference of Years with the date from the date provided in excel.
The Date present will have to be differentiated on based of the current date.
Here I have provided with excel sheet having dates.
DifferenceDate.xlsx (9.2 KB)
Can anyone suggest me with the solution please??

@Kunal_Jain

After reading the data into datatable…

Loopt hrough each row and use

now.year - Cdate(currentrow("date").ToString).Year

Or using linq

Create a newdt with one column with datatype as integer

Newdt = Dt.AsEnumerable.Select(function(x) now.year - cdate(x("date").ToString)).Copytodatatable

Cheers

@Kunal_Jain
you could transform the dates into datetime variable and then substract date1.year - date2.year.
Or you can operate with string operation to deduct the dates and substract them afterwards.

Could help me with the xaml please

Could help me with the xaml please?

@Kunal_Jain

You need only one assign activity for linq…just paste whatever you see above into assigna nd change the column names accordingly

And for build use build datatable and build newdt with one column

Cheers

ok
Thanks!!

1 Like


I am getting this error

@Kunal_Jain

Add .year at the end for cdate

Cheers

Here I am just getting the Year as the output without Date.
I need to match todays date with the date provided in excel and get the differnce.

@Kunal_Jain

Can you show what you tried as the one procided will give the difference between current year and the provided year in excel in a column directly

Cheers

@Kunal_Jain

Please check this…adapt to your files and columns

Kunal.zip (2.7 KB)

cheers

I am not able to get the required result.
Actually I need to get the difference in years based on current date and need to check that if the difference that we have found out is exact and no extra days has or month has been completed.
Example:
19-01-2023 - 19-01-2000 = The Result will Be exact 23 years.
But if we check,
19-01-2023 - 19-02-2000 = The Result will be 23 years and 1 month extra but according to the code it will give the difference of 23 years only.
So this will create error for the further process.
I need the result according to 1st example.
Can you please help??

@Kunal_Jain

Then use datediff(dateinterval.months,Now,Cdate(your date)) this will give difference in months…

Similarly you can change to day…minutes anything you need

Cheers

I am not able to get the solution for the same.
Actually what I want to is I will explain
First I need to check if the Year difference is between 5 or 10 or 15 and than I need to check for the current month that is currently today it is January so need to check how many are there for January month. Than I have to send the mail to them
How to do it??

@Kunal_Jain

As mentioned in previous comment use datediff function to get the required difference and then use if condition to compare if it is 5 or 10 or 15 and accordingly use send email

Say you need date difference between a date in varible date1 and today then

Datediff(dateinterval.months,Now,Date1) will give the difference of months between today and the date1

Cheers