Link to home
Start Free TrialLog in
Avatar of guster5k
guster5k

asked on

SQL String to sort Date & Time on the same field as Date Desc. and Time Asc.

I have a Date & Time field in access, i'd like a SQL string to sort the records by Date (i.e.: from today to 1 week ago) and then by time , but from 10am to 7pm (i believe it's ascending?).

Thanks
Avatar of normanpaterson
normanpaterson

Today to one week ago would be Descending (Desc)

Access has an excellent Help file, if you look up these terms you should be able to put together the necessary query:

DatePart, DateAdd, DateDiff


SELECT CustomerHistory.DateOfSale
FROM CustomerHistory
WHERE (((CustomerHistory.DateOfSale) Between Now() And DateAdd("m",-1,Now())))
ORDER BY CustomerHistory.DateOfSale DESC;
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice one Lowfatspread !
Avatar of guster5k

ASKER

I'd like to have something like:

ORDER BY DATE DESC AND TIME ASC

01/06/04 10:00AM
01/06/04 11:00AM
01/06/04 12:00PM
01/06/04 1:00PM
01/06/04 2:00PM

01/05/04 10:00AM
01/05/04 11:00AM
01/05/04 12:00PM
01/05/04 1:00PM

But the problem is that the date & time are on the same field.

Thanks a lot
Lowfatspread has posted a working solution to your problem
Did you try it ??
Yes :)