Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cmonth
Message
From
23/06/1999 16:15:23
 
 
To
23/06/1999 15:13:04
Dovi Gilberd
Dovtware Consulting Inc
Miami, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: Cmonth
Miscellaneous
Thread ID:
00233028
Message ID:
00233176
Views:
30
>fo i nee dto convert the character field to date....?
>i really dont need to, but what you showed me its not working

What's not working? What error message do you get when you try to do a CTOD("05/01/99")?

You can't do the CMONTH function unless you have a date type variable.

That's why you take the resultant string in a character date format, use CTOD to turn it into a date, and then use the CMONTH function to get the month (eg: June). Maybe your date format is not set to a month/day/year format? SET MONTH TO MDY, SET DATE TO AMERICAN

You have several options (VFP6):

Format your date string as a STRICTDATE format ({^yyyy-mm-dd}) and then do the CMONTH function on that...

Create a date type variable using the DATE function:

CMONTH(DATE(yyyy,mm,dd))

Note: the date for both of these syntaxes will require the century (19xx)
so that DATE(1999,5,1) would give you a date 05/01/1999. So you must do a VAL function on the substring values you are pulling from your date string:

CMONTH(DATE(VAL(SUBSTR(x,1,2)+1900,VAL(SUBSTR(x,3,2)),VAL(SUBSTR(x,5,2)))
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform