Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create a STOD command/function?
Message
From
01/05/2002 14:05:43
 
 
To
01/05/2002 12:08:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00651378
Message ID:
00651466
Views:
18
FYI:

Watch out for your SET STRICTDATE setting if using CTOD(). An error will occur at compile time if it's set to 2 and CTOD() is in the code.

>>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.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform