i had excel column which is having dates, I need to filter all today dates. it can me of any format like
MM-dd-yyyy
MM-dd-yyyy 00:00:00
MM/dd/yyyy
MM/dd/yyyy 00:00:00
dd-MM-yyyy
dd-MM-yyyy 00:00:00
dd/MM/yyyy
dd/MM/yyyy 00:00:00
i had excel column which is having dates, I need to filter all today dates. it can me of any format like
MM-dd-yyyy
MM-dd-yyyy 00:00:00
MM/dd/yyyy
MM/dd/yyyy 00:00:00
dd-MM-yyyy
dd-MM-yyyy 00:00:00
dd/MM/yyyy
dd/MM/yyyy 00:00:00
Yes you can
arrFormats = {"MM/dd/yyyy","MM/d/yyyy","M/dd/yyyy","M/d/yyyy"} datevalue = DateTime.ParseExact(closeDate, arrFormats, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat)
You can use tryparseexact as well
Cheers
can i use this code in c# but there can be more than 13 formats right so i should include all 13?
Yes you can use in c# as well
If there are different then you need to include them…
But one potential problem that you might get is using MM/dd/yyyy and dd/MM/yyyy as for example for dates less than 9 and month less than 9 …few dates might be parsed wrongly…so bear in mide to use carefully
Cheers