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

Save DATE Format Value into a TEXT Field ???

Status
Not open for further replies.

kev100

Programmer
Jun 20, 2006
28
US
I'm feeling kinda silly here....this can't be difficult.

I've been searching this forum and haven't been able to find a solution.

I need to store an existing value which is in the DATE format to a character (text) field.

I thought STR was it (e.g. TextValue = STR(DateValue)

But that causes an error.

Is the syntax incorrect on the STR function? Other?

Thanks very much.
 

You can either use :

replace fieldname with transform(Datefield)

or

replace fieldname with dtoc(Datefield)


 
Thanks very much...

TextField = Transform(DateField)

...works great.
 
In addition to mm0000 suggestion,
If you plan to index on that field, it would be efficient to convert to a string:
? DTOS(date())
**20070203
Also easier to compare, and or seek()

The only hassel here is to re-convert it back to a date()
cToday = DTOS(Date())
dToday = DATE(VAL(LEFT(cToday,4)),;
VAL(SUBSTR(cToday,5,2)),;
VAL(RIGHT(cToday,2)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top