I have the xlsx table. One of the columns is date (generally it is the number) in format:
201808
201809
201810
201811
201812
201901
201902
etc.
I would like to choose ony the rows (I use for each rows), where the above date is equal or smaller to previous month (201901). I have problem with date format to compare these two figures.
In result I should get date from 201808 to 201901.
I hope that someone help me.
Instead “201901” I used: Now.AddDays(-50).ToString(“yyyyMM”) - I have to get 201901 if I start proces eg. 2019-02-23 or 2019-03-10 - it is the reason that I use -50 days.
The error is: String was not recognized as a valid DateTime.mscorlib
Probably on first assign (DAte1) I have error:
String was not recognized as a valid DateTime.
and I can not solve this problem.
Finally I converted two figures to intiger and compare them:
Convert.ToInt32(row(“Date”)) <= Convert.ToInt32(New Date(Now.Year,Now.Month,Now.Day).AddDays(-50).ToString(“yyyyMM”))