I have a table with 2 ‘datetime’ fields: ‘eventDate’ and ‘eventHour’. I’m trying to order by ‘eventDate’ and then by ‘eventHour’.
For each date I will have a list os events, so that’s why I will to order by date and then by time.
thanks!!
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.
I’m not sure whether there’s any hidden meaning in your question but the standard way of doing this seems to fit:
That gives you hours within dates, like:
If you actually have those two fields as real
datetimefields, your schema is screwed up. You should have adatefield for the date and atimeor integral field for the hour.You could combine both into a single
datetimefield but you should balance that against the inefficiencies of doing per-row functions in yourselectstatements if you want to separate them. It’s usually better to keep fields separate if your going to use them distinctly.If you do have to use per-row functions, you can use:
to extract just the
dateandtimecomponents of adatetime.