sorting records in a database

robbie_62

Member
Joined
Jan 27, 2003
Messages
18
Location
ireland
hi there

i have 2 tables in my database,they have a primary key called date,there is a one to one relationship between the date field and the 2 tables.

I have a command to export the 2 tables to an excel sheet using the copy from recordset method.

My data in the db is not sorted so it look like

Date
01/02/02
02/02/02
03/03/03
04/04/02

When I export the data it is in the same format,Is there any way I can sort the db before I export the data ??
 
When you use your select Query

SELECT * FROM MyTable

use for ascending order

SELECT * FROM MyTable ORDER BY MyField Asc

or use

SELECT * FROM MyTable ORDER BY MyField Desc

for descending order

Hope this helps

Andy
 
EXPORT to excel

thanks for that but my problem is that is sorts the data as follows

date
02/01/03
02/03/03
02/08/02
02/09/02
02/10/02

I want it to be sorted by the date,month,year
so it should say

02/08/02
02/09/02
02/10/02
02/01/03
02/03/03




any ideas ?

My database field is set to text,because if i set it to date\time format the export to excel wont work.


:confused:
 
You should not be storing dates in text format. As you have seen, you cant sort by them and that is just one problem.

Your real problem here is that you cant export a date field to excel. I dont know why youre having a problem with that - it should work fine. Changing to text is not a solution.
 
export to excel

i know,Im using the copyfromrecordset method as from a microsoft sample project,it will not accept the date if i format the field as date\time format
 
export data

I have set my pc date format to dd/mm/yy

I have also set the fields in access to date time format and dd/mm/yy also.


any ideas ?
 
Back
Top