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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a String to DateTime

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I have a Character 20 field that I need to convert to a DATETIME field. Is this possible?
Thanks,

Leo ;-)
 
Well, what I would do, is create an new field that is a DateTime,

and
replace all NewField with ctot(oldField)

and then, remove the old field
and then, rename the new field to the old field name


this way you ensure data won't be lost in the conversion, since you are modifying structure for diffrent data types

Good luck!
Please let me know if this helped you :)

Tekno
Wireless Toyz
Ypsilanti, Michigan
 
Be careful that the format in the field matches the format required by DTOT() (which is dependent on the windows locality date/time settings on your computer)
 
Before you get started, review the help entry for VFP on 'alter table'. It will give step-by-step instructions on how to create the new date column in your table and delete the old date field programmitically. It's really simple and straight forward stuff, and an incredibly powerful tool.

Culleoka
 
If your data is not in the correct format for DTOT(), you can rearrange it into a format that is using the substring() command.

Brian
 
HI
When you say 20 character field, I assume that the format is correct... in which case..

myDateTime = CTOT(myDateTimChar)

YOu know how to write it to your file in a new dateTime field or whatever :)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top