How to give condition for Date Formats

debug this excel and share the screenshot of the resulting datatable with us.

The values that we see in Excel are not mandatory the same as we do get in the datatable. So we have to check if it is present in another format e.g. MM/dd/yyyy HH:mm:ss

give a try

Please see value is coming in dd/MM/yyyy hh:mm:ss, given the value in array

But after that

This is the array :{“dd-MMM-yyyy”,“dd-MM-yyyy”,“dd/MM/yyyy”,“dd/MM/yy”,“MM/dd/yyyy”,“MMM/dd/yyyy”,“M/d/yy”,“d/MM/yy”}

I have seen same for others also hh:mm:ss is coming in them but they are working fine

it looks like you are iterating within a for each row, so you can inspect the failing row / column value while debugging.

As the message box shows the different date format so it should be added to the formats list

with the given XAML (checking non valid date formats) you have an option / tool to analyse and to collect the missing formats

In debug also same value is coming

Actually i am getting datatable from different source , only this one is creating problem.

If am using simple CDate(Date) working fine , but creating issue for other,
your way is good but not working on this one only.

I just want to get months from this dates and add new column with values of Months

did you add it to the format array? MM/dd/yyyy HH:mm:ss

Hi ,
You are awesome, it is working for this one also.
It means we should also care about HH:mm:ss.

Thanks , you really a next level

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