How to compare two date (month and year)

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.


Hi @AaronMark

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

VariableDate.month < now.month
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)


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

1 Like