Xref: utzoo comp.sys.ibm.pc:15809 comp.databases:1019 Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!ll-xn!ames!pasteur!ucbvax!agate!violet.berkeley.edu!steve From: steve@violet.berkeley.edu (Steve Goldfield) Newsgroups: comp.sys.ibm.pc,comp.databases Subject: Re: dBase tricky INDEXing question... Message-ID: <10226@agate.BERKELEY.EDU> Date: 23 May 88 17:07:04 GMT References: <529@etn-rad.UUCP> Sender: usenet@agate.BERKELEY.EDU Organization: University of California, Berkeley Lines: 25 In article <529@etn-rad.UUCP> markus@etn-rad.UUCP (Markus Richardson) writes: Describing a problem in indexing on date. #Attempt 1: #SET EXACT OFF #USE Trans ALIAS Trans #INDEX ON LTRIM(STR(trans->account_no))+DTOC(trans->date) TO Trans.ndx I have a slightly different version of dBASE (McMax on a Macintosh) so if the below doesn't make sense, that's why. However, my manual says that DTOC gives you the date as 05/23/88 which is unsuitable for sorting in date order. DTOS, on the other hand gives you YYYYMMDD, i.e., 19880523, which is suitable for sorting or indexing. If you want reverse order, subtract from a large number, i.e., INDEX ON LTRIM(STR(trans->account_no))+ STR(100000000-VAL(DTOS(trans->date))) The simpler solution, which I've always used, is just to store dates as character strings or numbers. That's all you could do in the old dBASE I started with anyway. Incidentally, I tried to send this to you by email but you didn't list an address and our mail program couldn't handle it automatically.