Hello,
I have a date “10-01-1998” as dd-MM-yyyy format. I need to get this data
Years - 24 years
Months - 11 months
Days - 24 days
How do i do that?
Thanks in Advance
Hello,
I have a date “10-01-1998” as dd-MM-yyyy format. I need to get this data
Years - 24 years
Months - 11 months
Days - 24 days
How do i do that?
Thanks in Advance
Hi @404_Error
Try this-
parsedDate = DateTime.ParseExact(givenDate, “dd-MM-yyyy”, CultureInfo.InvariantCulture)
Use the “Assign” activity to calculate the time span between the parsedDate
and the current date. Subtract the parsedDate
from the current date, which can be obtained using the DateTime.Now
method. Assign the result to a variable, let’s call it timespan.
timeSpan = DateTime.Now - parsedDate
Thanks!!
Hey Thanks,
How can i get the Years, Months and Days from that?
Hi @404_Error
How about this expression
inputDate = DateTime.ParseExact("10-01-1998", "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)
currentDate = DateTime.Now
Then use Assign:
yearsDiff = currentDate.Year - inputDate.Year
monthsDiff = currentDate.Month - inputDate.Month
daysDiff = currentDate.Day - inputDate.Day
Then Use If :
Condition: daysDiff < 0
monthsDiff = monthsDiff - 1
daysDiff = daysDiff + DateTime.DaysInMonth(currentDate.Year, currentDate.Month)
Use another If activity:
Condition: monthsDiff < 0
yearsDiff = yearsDiff - 1
monthsDiff = monthsDiff + 12
Use Message box activity
Message Box:
"You are " + yearsDiff.ToString + " years, " + monthsDiff.ToString + " months, and " + daysDiff.ToString + " days old."
Regards
Gokul
Thank you so much for your help
I eliminated the negative values
but the values are different what i can see there
Thanks
Hi,
How did you get this value (24 years, 4 months, 23 days OR 9124 days)?
9124 days after Jan 10, 1998 is Jan 3, 2023, as the following.
Regards
Thanks mate, it works.
I Really Appreciate that.