How to compare two date (month and year)

Hi,
after a scraping, I collect dates from a web page, conformed: “MM.dd.yy”. I have to compare this date if it is less than or equal to today, but the verification must be done only on month and year.
Then if MM/yy (of scrap) < today (MM/yy)

how should the string be inserted? The collected date is in DateTime format.

Thanks

Hi @AaronMark

You should convert it to date and compare date by a month or year by

VariableDate.month < now.month
or
VariableDate.year < now.year

Check date is less than or equal to today condiion

(checkdate.Year < now.Year or (checkdate.Year = now.Year And checkdate.Month < now.Month)) or (checkdate.Year = now.Year And checkdate.Month = now.Month)

2 Likes

Hi…
@AaronMark convert your string variable of date to Date format
.
not CDate(stringDateVariable).ToString(“MM/yyyy”) > Now.ToString(“MM/yyyy”)

1 Like