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!

Replace a character date field with today's date or system date

Status
Not open for further replies.

foxprouserhelp1

Technical User
Mar 16, 2004
2
US
I am a new Foxpro user and am struggling a little bit with a character date field.

I have a charcter field that is populated with dates. (20040825 or 20040725, ect.). I need to update the field by changing the date to the system date/todays date (20040826).

Any input will be greatly appreciated.

Thank you
 
? dtos(date())

or

? TRANS(YEAR(DATE())) + ;
PADL(TRANS(MONTH(DATE())),2,"0") + ;
PADL(TRANS(DAY(DATE())),2,"0")

or many more variants

dtos() being the fastest and easiest

Darrell
 
Assuming that your character field is in a table named "mytable" and is named "mydate" the following snippet will replace the contents of your field in the current row of your table with the current system date in the same format as you have listed in your post: "20040826".

Replace mytable.mydate With DTOS(DATE())

Replace DTOS with DTOC to end up with "08/26/04"

Set Century On will result in "08/26/2004"

Check out the help facility to find other formats you might want to end up with.

CDavis
 
replace the field with dtoc( date(),1)
that will give you the format you need.

hth,

Stefan
 
similarly, you could use DTOS(DATE()) as an alternative to sir stefan's post.

peace! [peace]

kilroy [trooper]
philippines

"Illegitimis non carborundum!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top