Need to know the format of Enumerable x

I have below expression with me : -

ReadDT.AsEnumerable().Any(Function(x) Convert.ToDateTime(x(“Date”)).ToString = “16/09/19”)

I need to know what is the format of X in this expression ?

#learning

@sachinl If ReadDT is DataTable then x will be DataRow

In that case, it should return me true , if it is row… Because in my excel sheet 16/09/19 date is exist , but still this is returning false to me…

Can anyone help me in that ?

@sachinl When read the date from excel format of date as not same as what see in excel in most of the cases. In most of the cases time is also included but you unable to see it in your excel.

If you want to know the date format in your excel display using message box or write line.

@Manjuts90 → I have done this and also I am getting the exact case what you mentioning here, I am getting 00:00:00 with the date. And I am trying to mitigate the time but somehow I am not able to do it…

I use following expression :-

ReadDT.AsEnumerable().Any(Function(x) Convert.ToDateTime(x(“Date”).ToString).ToString = “17/09/19”)

but this still shows me False.

Is there any mistake in above expression ??

@sachinl

Try like below and check

ReadDT.AsEnumerable().Any(Function(x) Convert.ToDateTime(x(“Date”).ToString).ToString(“dd/MM/yyyy”) = “17/09/19”)

Hello @Manjuts90 → Its still showing false to me. I don’t know what’s happening…

@sachinl Please check the date format your are getting from excel and how many date formats are present in excel.

Hey @Manjuts90 → I have checked the format of dates in the excel only one format is there…

@sachinl Please check the format of date after reading from excel. can you upload sample excel if it is fine?

Hey @Manjuts90 → Please find the attached excel…

HolidayList.xlsx (5.5 KB)

Hello @sachinl

You are using this code and matching for this date 16/09/19 but in your sheet that date is not present

Try this code
DT.AsEnumerable().Where(Function(n) cdate(n("Date")).ToString("dd/MM/yy") = ("23/09/19") ).CopyToDataTable

@sachinl Please try like as @vickydas mentioned.