convert datetime to text

S

Student

is there a function in access like this
convert(varchar,mydatetimefield,120)

thx
 
R

Rick Brandt

Student said:
is there a function in access like this
convert(varchar,mydatetimefield,120)

Both the Format() and CStr() functions will do this. However, neither will
specify a length for the result.
 
T

Tim Ferguson

Both the Format() and CStr() functions will do this. However, neither
will specify a length for the result.

Surely Format$(SomeDate, "yyyy-mm-dd") is always exactly ten characters
long?


Tim F
 
R

Rick Brandt

Tim Ferguson said:
Surely Format$(SomeDate, "yyyy-mm-dd") is always exactly ten characters
long?

The OP was looking for an equivalent to
convert(varchar,mydatetimefield,120). In SQL Server when you convert a
date to a string like this you specify a length for the "converted to"
VarChar field. I was just pointing out that using the Access conversion
functions the field length will just be whatever the longest output value
is (not a length that he specifies in the function).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top