|
| Re: Create an index on the date field with older dates first. |
 |
Tue, 15 Jan 2008 13:13:27 -080 |
Matthew wrote:
> Hello,
>
> I am successful in creating an index in dBASE 5.0 for DOS. But when
> displaying the index it has the newest dates at the top and oldest at
> the bottom. How can I reverse those?
>
> Here is my current code.
>
> USE WORDR INDEX ON ASGNAME + SUBSTR(DTOS(PLAN), 1, 2) +
> SUBSTR(DTOS(PLAN), 7,4) + SUBSTR(DTOS(PLAN),4,2) + NHOUR +
> DTOS(SERVD2) + PHOUR TO WORDPX
>
> NOTES: The PLAN variable is a date, so it needs to be converted to
> work with the other variables. So far the first one is the year, the
> second is the day and the third is the month. This will correctly
> sort it with my 10 test records. Except I want the oldest date first
> in the list. :-)
The problem here is that if you want it descending, the DESCENDING flag
for creating an index affects the whole index. I am curious why you're
sorting year, day and month ... seems a bit odd, to me. The default for
DTOS() is year, month, day ... which makes more sense, as it keeps the
days of the month together for that month ...
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
|
| Post Reply
|
| Re: Create an index on the date field with older dates first. |
 |
Tue, 15 Jan 2008 13:25:52 -080 |
I think you might not understand the function dtos().
It should produce an ascending index without using subst().
For example:
?date() //01/15/2008
?dtos(date()) // 20080115 //YYYYMMD
plan = date()
?SUBSTR(DTOS(PLAN), 1, 2), SUBSTR(DTOS(PLAN), 7,4), SUBSTR(DTOS(PLAN),4,2)
// 20 15 80
??SUBSTR(DTOS(PLAN), 1, 2)+SUBSTR(DTOS(PLAN), 7,4)+SUBSTR(DTOS(PLAN),4,2)
//201580
That part of the index expression probably isn't doing what you wanted.
Eric
> Hello,
> I am successful in creating an index in dBASE 5.0 for DOS. But when
> displaying the index it has the newest dates at the top and oldest at the
> bottom. How can I reverse those?
> Here is my current code.
> USE WORDR
> INDEX ON ASGNAME + SUBSTR(DTOS(PLAN), 1, 2) + SUBSTR(DTOS(PLAN), 7,4) +
> SUBSTR(DTOS(PLAN),4,2) + NHOUR + DTOS(SERVD2) + PHOUR TO WORDPX
> NOTES: The PLAN variable is a date, so it needs to be converted to work
> with the other variables. So far the first one is the year, the second is
> the day and the third is the month. This will correctly sort it with my 10
> test records. Except I want the oldest date first in the list. :-)
> Thanks!
|
| Post Reply
|
| Create an index on the date field with older dates first. |
 |
Tue, 15 Jan 2008 15:58:16 -050 |
Hello,
I am successful in creating an index in dBASE 5.0 for DOS. But when displaying
the index it has the newest dates at the top and oldest at the bottom. How can I
reverse those?
Here is my current code.
USE WORDR
INDEX ON ASGNAME + SUBSTR(DTOS(PLAN), 1, 2) + SUBSTR(DTOS(PLAN), 7,4) +
SUBSTR(DTOS(PLAN),4,2) + NHOUR + DTOS(SERVD2) + PHOUR TO WORDPX
NOTES: The PLAN variable is a date, so it needs to be converted to work with the
other variables. So far the first one is the year, the second is the day and the
third is the month. This will correctly sort it with my 10 test records. Except
I want the oldest date first in the list. :-)
|
| Post Reply
|
| Re: Create an index on the date field with older dates first. |
 |
Wed, 16 Jan 2008 08:19:42 -050 |
In article <6UFwZl7VIHA.1304@news-server>, MRockhold@walzeq.com says...
> Hello,
>
> I am successful in creating an index in dBASE 5.0 for DOS. But when
> displaying the index it has the newest dates at the top and oldest
> at the bottom. How can I reverse those?
>
> Here is my current code.
>
> USE WORDR
> INDEX ON ASGNAME + SUBSTR(DTOS(PLAN), 1, 2) + SUBSTR(DTOS(PLAN), 7,4) + ;
> SUBSTR(DTOS(PLAN),4,2) + NHOUR + DTOS(SERVD2) + PHOUR TO WORDPX
>
I've seen an index similar to this used:
index on asgname + ;
str((plan - ctod(12/31/1900)),10,0) + ;
nhour + dtos(servd2) + phour ;
to wordpx
(assuming you want the plan date in descending order and not the servd2
date)
--
Marilyn Price
|
| Post Reply
|
|
|