Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL : Can I use Select... Order By SUBSTR(xxxxx) ?
Message
From
09/08/1999 12:16:54
 
 
To
09/08/1999 12:09:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00251237
Message ID:
00251552
Views:
9
>Ed,
>
>Hmmm... thanks for the info. It is a very important problem to the program, which I didn't realised before. So, how do I store them as date, in 99/99 format? Just change the data type as date? Then when retrieving data, just set them as SUBSTR(date,4,5)?
>

I've gotten in the habit of always using a date field for the representation, and then forcing the date for the month to the first of the month when I want to ignore the day. This now lets me handle sorts trivially; no SUBSTR() is needed, and if I need to concatenate a key, I can use the DTOS() of the date field.

You'll need to write a bit of code to handle the data representation in forms to allow entry into a text field and convert it to and from a date field. It's not all that tought to do, and you just do it once in a textbox class that handles that particular data entry task, and then use the textbox class as needed. You can create the MM/YY output in reports and for displays pretty trivailly using the MONTH() and YEAR() functions.

>Gan
>
>>
>>lets take a simple example where you want things sorted in ascending order, and you have an entry in December of 1999, which you've stored as 12/99, and another in January of 2000, which you've stored as 01/00. You use your sort expression given in the sample code. Which one will appear first?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform