I have following Date Time in my database. If my current system Date time is “2012-11-24 03:50:00.000”, then there should be output as 3rd record. How can I get it by linq query?
1 2012-11-24 01:00:00.000 35466 True False
2 2012-11-24 01:00:00.000 35466 True False
3 2012-11-24 01:15:00.000 35466 True False
4 2012-11-23 01:10:00.000 65456 True False
If you don’t absolutely have to do the query server-side, then the following pseudocode method will work:
In C#, you can calculate time intervals easily with the
DateTime.Substractmethod, and take the absolute value of the returnedTimeSpanobject’sDaysproperty, for example.I am not too expert with SQL date manipulation, but I believe you can do the same sort of thing server side with something similar to:
and then use the first value.
Sorry, I just noticed you want it in LINQ format, which lets you combine server side and client side work–something similar to this: