How can I group result of a LINQ to SQL query by hours considering that the column type is DateTime?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a solution for technical hours (context-less).
Which generates this:
Here’s a solution for business hours (context-ful) .
Which generates this:
Ugh – that bigint/float/milliseconds stuff is ugly and hard to verify. I prefer doing the addition back on the client side:
Which generates this:
And here’s a third way of doing the contextful hours. This one is very c# friendly, but there’s string logic in the database (yuck).
Which generates