Skip to content
Advertisement

Datetime fetch incorrect data for second iteration

I have this query :

It gives me 2nd row as an output which is correct. Because time is 15:11:00.000.

Now If I pass

And I run the above query it still gives me the same output, But I want to show the 1st row as an output. What changes do I need to make to satisfy both the requirement with 1 query?

The reason I want to show the 1st row as an output: Because the enddate which is being passed is near to the end date of the 1st row, I can write the second query to fetch the data, But I need just 1 query wherin both the condition should be satisfied.

I tried this as well:

But I am still getting the same output.

Advertisement

Answer

Can you please try this below logic-

DEMO HERE

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement