Hi,
Currently im working on a process where i need to filter two datetime columns.
This is the data table here i want to filter data [Sales Date] = DateTime.now.ToString() and [Action taken on] >= DateTime.now.Adddays(-1) and [Action taken on] <= DateTime.now.ToString()
And the below is the expected result
I tried this but its not returning any values.Please help… TestSample.xls (27.5 KB)
Hi Yes. Its an or condition since i want any one of them to be true. But if i want to filter yesterday to today, do i need to apply AddDays(-1)?
(From dr As datarow In DtP Where DateTime.FromOADate(Double.Parse(dr.item(“Initiated On”).ToString)).Date=Today Or DateTime.FromOADate(Double.Parse(dr.Item(“Action taken on”).ToString)).Date<=Today AndAlso DateTime.FromOADate(Double.Parse(dr.Item(“Action taken on”).ToString)).Date>=New Date(DateTime.Now.AddDays(-1))Select dr.ToArray
Remember that dates has time too, so if u compare date = today than you will get only results like:
20/03/2021 00:00:00
Thats why there is >= operator If in that column can appear future date (like tomorrow) than u need to add two conditions
date>=Today and date < Today.AddDays(1)
Thanks @noufalahammed i tried it but still its showing error
(From dr As datarow In DtP Where DateTime.FromOADate(Double.Parse(dr.item(“Initiated On”).ToString)).Date=Today Or DateTime.FromOADate(Double.Parse(dr.Item(“Action taken on”).ToString)).Date<=Today AndAlso DateTime.FromOADate(Double.Parse(dr.Item(“Action taken on”).ToString)).Date>=New Date(DateTime.Now.AddDays(-1).Date) Select dr.ToArray