Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Order Event Times from AM to PM?
Message
From
09/04/2001 18:11:59
 
 
To
09/04/2001 16:28:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00493754
Message ID:
00493826
Views:
17
Brad,

I tried your suggestion and worked it further as shown:

SELECT ;
iif(right(substr(time,1,2),1)=":", padl(substr(time,1,1),2,"0"),substr(time,1,2));
+ iif(at("AM", time)=0,"PM","AM");
+ iif( at(":", time)=2, substr(time,3,2), substr(time,4,2) ) AS timesort,;
* ;
FROM ;
PROPOSAL ;
ORDER BY ;
date, timesort ;
INTO ;
CURSOR c_PROPOSAL

It seems that this puts me on the right track with "timesort" substituted for "time" in the ORDER BY and printing the actual time values from the "Time" field but the timesort field is showing all xxPMxx times first in the column before the xxAMxx times, so I still have some work to do here to get it correct.

Thanks for your response.
Mark


>Assuming all data is in XX:XX?M or X:XX?M format, you could do:
>
>
>SELECT ;
>  LEFT(PADL(timefield,7),2)+RIGHT(PADL(timefield,7),2)+SUBSTR(PADL(timefield,7),4,2) AS timesort,;
>  * ;
>FROM ;
>  mytable ;
>ORDER BY ;
>  1 ;
>INTO ;
>  CURSOR result
>
>
>This will construct a "timesort" field that will consist of the Hour, then the AM/PM part, then the minutes. So 10:45AM will come out "10AM45" and 7:30AM will come out " 7AM30"
>
>Then you can do a COPY TO...FIELDS to copy out only the fields that you want in your final file.
>
>Will this work for you?
>
>--Brad
Mark Rietman
Previous
Reply
Map
View

Click here to load this message in the networking platform