While reading excel data for time base it is throwing error

Hi to all,

I am getting error like “Assign: Conversion from string “” to type ‘Double’ is not valid.” after reading the excel sheet.
this is the logic
(From r In Dttime.AsEnumerable
Where datetime.FromOADate(CDbl(r(“Time”).ToString)).ToString(“HH:mm:ss”) > “06:00:00” And datetime.FromOADate(CDbl(r(“Time”).ToString)).ToString(“HH:mm:ss”) < “11:59:59”
Select r).CopyToDataTable
It should filter the data with in the given time.

@Harish_pavuluri - Based on the excel sheet you provided in the below post, this should work without any error…If your column has Null or Space value it will throw an error which you have to handle this before filtering the data

screenshot of the filtered sheet with 678 rows out of 1878 rows in the sheet1

Tks for reply.

I saved in the main process what you create, There i got that error.

I have a doubt in this. Why it is differ for excel to excel ?

I guess you have empty rows in your excel

Plz check with this excel, I got this format recently.
Party wise cumulative Report.xlsx (279.4 KB)
In for each loop I used massage box for checking the out put of the data it is showing same 0.78 and 0.89 something like.

@Harish_pavuluri - As i suspected there is blank value in the Time Column and that’s why it was failing. Have you checked and made any attempt to remove it??

Hey @Harish_pavuluri

Quick check:

(From r In Dttime.AsEnumerable
Where datetime.FromOADate(CDbl((r(“Time”).ToString)).ToString(“HH:mm:ss”)) > “06:00:00” And datetime.FromOADate(CDbl((r(“Time”).ToString)).ToString(“HH:mm:ss”))< “11:59:59”
Select r).CopyToDataTable

Can you try with the above query, I have added one more parenthesis while converting into Double.

Br,
Goutham

Hi @GouthamVijay - Initial query provided by me in his previous post works like a charm…The reason why it is failing is Time Column has a blank data.

So i just used another LINQ query to filter the Non Blank and ran the same code previous used and it ran successfully.

2 Likes

THaks for your suggestion I will try and tell you that.
That blank row for sub total row, I am trying to remove that.

1 Like

@Harish_pavuluri - Either you can remove it manually or apply the filter as I shown above, after filtered just pass the filtered dt existing codes…it is working fine…I have already tested it.

It’s working after deleting last row

Thanks for you support.

1 Like

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