Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String Conversion
Message
From
03/08/2007 22:21:36
 
 
To
03/08/2007 22:05:27
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01245922
Message ID:
01245927
Views:
24
This message has been marked as the solution to the initial question of the thread.
My formula was for the format mm/dd/yyyy, I'll bet your working with dd/mm/yyyy. In that case you should do:
? left(cmonth(CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4))),3) + [ - ] + RIGHT(m.lcdate,4)

*To use the cmonth function you need a complete date, and since you were
*missing day of the month, you fill in day with "01", but since we are in
*different countries the standard is different.

* Step-by-step here is what is happening

* this gives you the month
? LEFT(m.lcdate,2)

* this gives you the year
? RIGHT(m.lcdate,4)

* this creates a character string in the date format adding in the first of the month
? [01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4)

* this converts the characther string into a date type
? CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4))

* this gets the alpha month 
? cmonth(CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4)))

* this truncates the month to the first 3 characters
? left(cmonth(CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4))),3)

* this adds the dash back in
? left(cmonth(CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4))),3) + [ - ]

* this tacks the year on to the end
? left(cmonth(CTOD([01/]+LEFT(m.lcdate,2)+[/]+RIGHT(m.lcdate,4))),3) + [ - ] + RIGHT(m.lcdate,4)
Oh and don't call me dear. :)

>Hello Dear
>
>07-2006 shows Jan-2006 due to this word in forumula
>[/01/]
>
>Please correct
>I think month number should not given in formula,
>If I use this function
>
>LEFT(CMONTH(CTOD(LEFT(pay.month,2)+alltrim(substr(pay.month,2))+RIGHT(pay.month,4))),3)+[ - ]+RIGHT(pay.month,4)
>
>Then it display
>*ba - 2006
>
>Please help
Carole Shaw
Fred Hutchinson Cancer Research Center

Eagles may soar, but weasels don't get sucked into jet engines.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform