Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create a STOD command/function?
Message
From
01/05/2002 12:08:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
01/05/2002 11:58:26
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00651378
Message ID:
00651389
Views:
44
>Hi all,
>
>I have a character field that is a date in mmddyyyy format. I need to sort the file by this serv_date field.
>
>There is a DTOS (Date To String) command, but no inverse STOD (String To Date). Currently I am using:
*)******************************************************************************
>*) we change serv_date from looking like
>*) "06251998" to look like "06/25/1998"
>*)------------------------------------------------------------------------------
>m.serv_date = SUBSTR(serv_date,1,2) + "/" + SUBSTR(serv_date,3,2) + ;
>"/" + SUBSTR(serv_date,5,4)
Then I use CTOD(m.serv_date). Since the table is over 5.5Meg records, this takes a while using a SEEK inside of a scan. What is frequently requested is that I create a new table based on serv_date from a particular date to a particular date. Then create a "KILL" table with serv_date between the last particular date till DATE(). The table crosses the Y2K boundary, so that is also a challenge, especially in FPW2.6. I have thought about changing the field to a date format, but that would mean changing numerous programs across several projects. If there's no other way, then that's the way I'll go.
>
>Does anybody know of a faster/better way to do this? Maybe something in SQL? I'm not smart enough to figure it out.
>Help!!
>
>TIA
>Pete

The stod() function would be something like this:
lparameters cDate
cDate = padl(nMonth, 2, "0") + "/" + padl(nDay, 2, "0") + "/" + str(nYear, 4)
return ctod(cDate)
This is only a quick-and-dirty solution - beware of changes to the date format (SET DATE). You may want to change and restore it within your function.

HTH, Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform