Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2005, 05:23 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date/Time Sort Question

I want to sort the date portion of the date/time field, desc, and the time portion of the date/time field, asc. Is there a simple method for me to be able to accomplish this? In other words, I want the most recent date to be sorted first, but within the date to be sorted in a normal 8am to 5pm sequencing.
I'm new to date/time fields in access (as a matter of fact, I just found out that all dates hold time references). If anyone has a good tutorial reference for date/time field questions, I'd appreciate the info.
 
Old April 21st, 2005, 11:14 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default


You will want to add two new fields to your table and do an update query to take the Date/Time field, and split it into one Date field, and one Time field. Then don't store your data as Date/Time anymore.



mmcdonal
 
Old April 23rd, 2005, 09:18 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

mmcdonal is right. But I don't think you need to go to the trouble of changing your table. Whenever you need that sort, just build fields in your query like this:

SELECT Table1.Datefld, Format([Datefld],"yyyymmdd") AS DateSort, Format([Datefld],"hh:mm:ss") AS TimeSort
FROM Table1
ORDER BY Format([Datefld],"yyyymmdd") DESC , Format([Datefld],"hh:mm:ss");

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL group/sort by date problem athos XSLT 4 October 7th, 2008 09:35 AM
sort by question elladi Classic ASP Databases 1 March 29th, 2005 11:12 AM
sort by date mysql crmpicco Classic ASP Databases 1 March 4th, 2005 06:55 AM
VB6 ListBox Sort by Date luxcs Beginning VB 6 2 September 28th, 2004 10:26 AM
sort by last post time doesn't work? amarelo Forum and Wrox.com Feedback 1 June 6th, 2004 09:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.