IBM developerWorks
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 22nd, 2003, 12:51 AM
Freddyfiasko's Avatar
Freddyfiasko Freddyfiasko is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Norway
Posts: 57 Freddyfiasko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 33 sec
Reputation Power: 7
Order by date with MS Access

How can I "order by" a field containing a date/time with MS Access? Think I need to insert a kind of "sysdate" but cant find any info about it.

Freddy

Reply With Quote
  #2  
Old July 22nd, 2003, 02:47 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Order by field ASC | DESC

Reply With Quote
  #3  
Old July 22nd, 2003, 03:01 AM
Freddyfiasko's Avatar
Freddyfiasko Freddyfiasko is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Norway
Posts: 57 Freddyfiasko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 33 sec
Reputation Power: 7
I did mean how to insert some kind of sysdate in MS Access. Must use a date in db-format if I want to order by a date.

Reply With Quote
  #4  
Old July 22nd, 2003, 03:14 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Are you inquiring about how to create a date field so that you can order by it? What version of MS Access are you using? You should be able to add a date/time field and select the format from the Design View.

Reply With Quote
  #5  
Old July 22nd, 2003, 05:10 AM
spc197's Avatar
spc197 spc197 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: North East of England
Posts: 23 spc197 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 38 m 28 sec
Reputation Power: 0
If you have the field to hold the date time

In your insert statement use

insert into tbl_table (thedate) values (#'&now()&'#)

This will give you table the date and time it was inserted

The when you select

select * from tbl_table order by thedate

Reply With Quote
  #6  
Old July 22nd, 2003, 11:54 AM
Freddyfiasko's Avatar
Freddyfiasko Freddyfiasko is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Norway
Posts: 57 Freddyfiasko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 33 sec
Reputation Power: 7
Thanks, spc197!

That was it.

Didn`t know that I could use an asp-date for this, but now i do :-)

Reply With Quote
  #7  
Old July 22nd, 2003, 08:21 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,344 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 30 m 33 sec
Reputation Power: 891
even better, use the internal date that Access provides --

insert into tbl_table (thedate)
values ( now() )

or date() if you don't want the time portion

rudy

Reply With Quote
  #8  
Old August 6th, 2003, 06:31 AM
zeromeg zeromeg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 zeromeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm pulling information from a phone system via an ascii file and then putting it in a database. It is an Access database. I have one field with the date and another with the time.

When I report based on hour it sorts them as follows:

1
10
11
12
13
2
3
4
5
6
7
8
9

I'd like the report I'm generating to be in proper hour order:

00
01
02
03
04
05
06
07
08
09
10
11
12
13

Trying to create my own date/time value in my query doesn't seem to do it. Before I start going crazy changing the data and the import process is there a way to do this in my query or will it work if I make a new field with both date and time?

Reply With Quote
  #9  
Old August 7th, 2003, 02:49 AM
Freddyfiasko's Avatar
Freddyfiasko Freddyfiasko is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Norway
Posts: 57 Freddyfiasko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 33 sec
Reputation Power: 7
Have you defined the time-field as date/time? I think you have to do that to make access interprete the values as date/time. Then you should be able to sort them right...

Freddy

Reply With Quote
  #10  
Old August 7th, 2003, 04:36 AM
zeromeg zeromeg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 zeromeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes it is set as a date/time field and I specified the format be short time XX:YY which matches the data in. However, I need to group by the hour XX and so I used Left in my SQL. I switched to using DatePart('h',entryTime) and now it is working...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Order by date with MS Access


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway