DataTime 1 month

Hello
I have a variable that fetches dates from a web page, is there a way to check if it has been 1 month past that date?
Thanks

@dcmf
Welcome to the forum

Yes, can you please share some sample so we can refer to the used date format string. This will decide which approaches will best fit for the case. Thanks

Hi,

Use this function
(date.Now-webpageDate).Days will give you days difference

1 Like

Thanks.
Basically the date on the website is something like this: “26 of January of 2021” but i convert to DataTime in this format: 26/01/2021 00:00:00
But i want verify if already pass 1 month between date on the website and atual date, to create a condition.
Thanks

Perfect. Once Parsed into a DateTime the internal representation is as you mentioned:
01/26/2021 00:00:00 we do not touch this

then with a compare date e.g. now we can the check interval.
e.g. on Timespan base
grafik

DateDiff would look like this but is not returning fractions:
grafik
Kindly note:
grafik
is returning 1 as date was in September for a count of 20 days

as an alternate we can bring it also on following check:
grafik

1 Like

Datetimes don’t have a format. You format them when you output them.

If you have Parsed “26 of January of 2021” into a datetime, and have a second datetime to compare to, then you can use DateDiff to get the number of days, weeks, months etc between the two datetimes.

1 Like

Hope the below expression would help you validate whether it has crossed a month or not

Let’s take like you have the input in Strinput

  1. First use a assign activity like this

Strinput = String.Join(“/“,Split(Strinput.ToString,” of “)).ToString

Use this expression in IF activity

(Convert.ToInt32(Datetime.ParseExact(Strinput.ToString.Trim,”dd/MMMM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”))-Datetime.Now.Month)>1

If true it has passed one month and goes to THEN block

Cheers @dcmf

2 Likes

One minor correction…if subtraction works the same as datediff, a result of 1 means more than 1 month has passed, because it calculates full months that have passed. A result greater than 1, ie 2, means 2 full months have passed.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.