Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Change date save in string format to back date format

Status
Not open for further replies.

shahid

Programmer
Mar 7, 2000
7
US
I have foxpro database that save date in string format<br>
example 20000201 . How can i print or display back in date<br>
format example 02/01/2000<br>

 
You didn't mention if your date format is mm/dd/yyyy or dd/mm/yyyy, but:<br>
<br>
Pretending that your field name is &quot;MyDate&quot;, try this:<br>
<br>
CTOD(SUBSTR(MyDate, 5, 2) + &quot;/&quot; + ;<br>
SUBSTR(MyDate, 7, 2) + &quot;/&quot; + ;<br>
LEFT(MyDate, 4))<br>
<br>
If you are using VFP 6, then the preferable technique would be:<br>
<br>
CTOD('^' + LEFT(MyDate, 4) + &quot;-&quot; + ;<br>
SUBSTR(MyDate, 5, 2) + &quot;-&quot; + ;<br>
SUBSTR(MyDate, 7,2) )<br>
<br>
or the somewhat simpler:<br>
<br>
DATE(LEFT(MyDate, 4), ;<br>
SUBSTR(MyDate, 5, 2), ;<br>
SUBSTR(MyDate, 7, 2))<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top