Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Update -Set Command - Problem with using date
Message
From
21/06/1999 09:55:40
 
 
To
21/06/1999 08:14:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00232040
Message ID:
00232089
Views:
16
>I download data from a remote source and unfortunately the date field comes down as a character field - '19990507'(8 character) - I want to convert the character field to a date field. Since I am also parsing a number of other fields I used the Update command and it has worked fine except now when I need to convert a date field. I tried to use the date() function and convert the year,month and day to values as follows
>datefield = (8) date
>char_date = (8) character
>
>UPDATE tablename;
> SET datefield = date(val(left(char_date,4)) ,val(substr(char_date,5,2)) ,val(right(char_date,2)))
>
>I get an error message (invalid function,procedure etc etc)
>

How about changing the SET to:

SET datefield = EVAL("{^"+left(char_date,4)+'-'+SUBST(char_date,5,2)+'-'+RIGHT(char_date,2)+'}')

>
>I also tried to use "{"+left(char_date,4)+"-"+subs(char_date,5,2)+;
>"-"+right(char_date,2)"}" including macro substitution and about every variation of this and it doesn't work.
>
>
>
>If I do the following I can update the table, however it sets all dates to the date in the first record. Unfortunately the dates are not all the same in the table and while it works it gives the wrong results.
>
>use tablename
>lnYr =val(left(char_date,4))
>LnMo = val(substr(char_date,5,2))
>LnDay = val(right(char_date,2))
>
>UPDATE tablename;
> SET newdatefield = date(lnYr,lnMo,LnDay)
>
>
>
>I can use the scan and replace commands and solve the problem, however I really don't want to rewrite a bunch of code.
>
>I am now appealing for help for one more knowledgeable than me on how to convert a character string to a date field using the update command. Any and all help will be appreciated. Could this be a "bug"!!!
>
>Gaylen Jungling
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