Connecting Tech Pros Worldwide Help | Site Map

How to sort table data?

  #1  
Old November 13th, 2005, 09:59 AM
deko
Guest
 
Posts: n/a
I need to import dates from a linked table then export them out as text to
an Excel spreadsheet. The problem is the dates need to be in ascending
order when I dump them out to Excel - and there's no telling what order they
are in in the linked table.

I've tried this:

INSERT INTO tblExcelData
SELECT [MeasurementId] AS TestID, [MeasurementDate] AS MeasDate,
[MeasurementTime] AS MeasTime
FROM Measurement
ORDER BY [MeasurementDate], [MeasurementTime];

But the dates don't appear in ascending order in tblExcelData.

When I dump them out to Excel, I'll need to concatenate:

MeasDate + " " + MeasTime (this is the text string goes to Excel - needs to
be text...)

So I need some way to sort the table while the data is in date format before
running another query to export as text into Excel.

What's the best way to sort the data in the table? Do I need an index?

Thanks in advance.



  #2  
Old November 13th, 2005, 10:00 AM
Arno R
Guest
 
Posts: n/a

re: How to sort table data?


In your table 'Measurement' are the fields MeasurementDate and MeasurementTime date/time-fields or text?
You will need date/time fields to sort on.
[color=blue]
> What's the best way to sort the data in the table? Do I need an index?[/color]
When you use an autonumber as index, when your insert-query-records are in the right order, you will be allright.
Is there an index (maybe TestID) in your tblExcelData now?

Arno R

"deko" <deko@deko.com> schreef in bericht news:mG_7e.2826$t85.1262@newssvr21.news.prodigy.co m...[color=blue]
>I need to import dates from a linked table then export them out as text to
> an Excel spreadsheet. The problem is the dates need to be in ascending
> order when I dump them out to Excel - and there's no telling what order they
> are in in the linked table.
>
> I've tried this:
>
> INSERT INTO tblExcelData
> SELECT [MeasurementId] AS TestID, [MeasurementDate] AS MeasDate,
> [MeasurementTime] AS MeasTime
> FROM Measurement
> ORDER BY [MeasurementDate], [MeasurementTime];
>
> But the dates don't appear in ascending order in tblExcelData.
>
> When I dump them out to Excel, I'll need to concatenate:
>
> MeasDate + " " + MeasTime (this is the text string goes to Excel - needs to
> be text...)
>
> So I need some way to sort the table while the data is in date format before
> running another query to export as text into Excel.
>
> What's the best way to sort the data in the table? Do I need an index?
>
> Thanks in advance.
>
>
>[/color]
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there an easy way to sort a list by two criteria? neocortex answers 5 February 11th, 2008 01:05 PM
how to sort the table using combo box values Nirmala123 answers 5 July 6th, 2007 12:13 PM
Is there method to sort my dataset table with one or mulitple colu =?Utf-8?B?UHVjY2E=?= answers 3 February 1st, 2007 03:05 AM
How to sort table with VBA Troy answers 9 July 19th, 2006 12:35 AM