|
Home > Archive > FoxPro Help and Support > June 2005 > How to convert mdy(date()) back to the original date()?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to convert mdy(date()) back to the original date()?
|
|
|
| How can I convert mdy(date()) back to the original date()?
date() returns 06/29/05
mdy(date()) returns June 29, 05
ctod(mdy(date())) returns / /
How can I convert a character value like June 29, 05 to 06/29/05?
Thanks.
| |
| Fred Taylor 2005-06-30, 3:24 am |
| DIMENSION aMonths[12]
FOR x=1 TO 12
aMonths[x] = CMONTH(DATE(2005,x,1
))
ENDFOR
cDate = MDY(DATE())
SET DATE AMERICAN
FOR x=1 TO 12
IF cDate=aMonths[x]
cDateString = SUBSTR(cDate,AT(" ",cDate)+1)
cDateString = TRANSFORM(x,"99") + "/" + STUFF(cDateString,AT
C(",
",cDateString),2,"/")
dDate = CTOD(cDateString)
EXIT
ENDIF
ENDFOR
? dDate
--
Fred
Microsoft Visual FoxPro MVP
"Peter" <Peter@discussions.microsoft.com> wrote in message
news:8246A508-FC1B-4F4B-85A1- FDA8059DFC02@microso
ft.com...
> How can I convert mdy(date()) back to the original date()?
>
> date() returns 06/29/05
> mdy(date()) returns June 29, 05
> ctod(mdy(date())) returns / /
> How can I convert a character value like June 29, 05 to 06/29/05?
>
>
> Thanks.
>
| |
|
| Hi Fred,
Thanks for the coding. I wonder why VFP does not include a function for
this. Most of the other VFP date functions have the corresponding reverse
functions.
Peter
"Fred Taylor" wrote:
> DIMENSION aMonths[12]
> FOR x=1 TO 12
> aMonths[x] = CMONTH(DATE(2005,x,1
))
> ENDFOR
> cDate = MDY(DATE())
> SET DATE AMERICAN
> FOR x=1 TO 12
> IF cDate=aMonths[x]
> cDateString = SUBSTR(cDate,AT(" ",cDate)+1)
> cDateString = TRANSFORM(x,"99") + "/" + STUFF(cDateString,AT
C(",
> ",cDateString),2,"/")
> dDate = CTOD(cDateString)
> EXIT
> ENDIF
> ENDFOR
> ? dDate
>
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>
> "Peter" <Peter@discussions.microsoft.com> wrote in message
> news:8246A508-FC1B-4F4B-85A1- FDA8059DFC02@microso
ft.com...
>
>
>
| |
| Cindy Winegarden 2005-06-30, 9:24 am |
| Hi Peter,
My guess is that it's just not all that useful. Most of the time you'd want
to spell out the date would be on a report. Users would very seldom enter
dates in strings like that. It's too variable since what you get depends a
lot on what the Windows date settings are on the client computer.
--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
cindy_winegarden@msn
.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"Peter" <Peter@discussions.microsoft.com> wrote in message
news:ABA8F603-7584-4E87-9B06- FB34352A7466@microso
ft.com...
> ... I wonder why VFP does not include a function for
> this. Most of the other VFP date functions have the corresponding reverse
> functions.
[color=darkred]
|
|
|
|
|