date to string convert function

0

00Eric Clapton

What is the function which can convert date field to string in a specific
format? Thanks.
 
M

Marshall Barton

00Eric said:
What is the function which can convert date field to string in a specific
format?


The function you're looking for is Format()

Check Help for the function and the Format Property for
details.
 
0

00Eric Clapton

Actually, a field value 7/7/05 and how do I change it to 07072005 as a
string? Thanks.
 
0

00Eric Clapton

And how I change a field with value 1 to " 1" with leading 5 empty space
and string datatype?
 
A

Albert D.Kallal

Actually, a field value 7/7/05 and how do I change it to 07072005 as a
string? Thanks.

As others mentioned, you can use the format function.

Thus,

format(dateValue,"mmddyyyy")

So in a report, you could place a text box on the report, and bind it to the
following expression:

=(format([mydatefield],"mmddyyyy"))

In code, you could use:

dim dtMyDate as date


.....code here sets the date value from the table, or whatever....

msgbox "the date value is " & format(dtMyDate,"mmddyyyy")

It is not clear when, or where you want this value displayed. And, as
mentioned, it is assumed the data is in a date type field...
 
G

Graham Mandeno

Five spaces followed by a numeric value? Try:
" " & MyValue

This may not give you what you want if the value is, say, greater than 9,
but then you do not have a good history for expressing your questions
clearly, nor, indeed, for showing gratitude for the learned advice you do
receive.
 
J

John Griffiths

How about ->

Space(5-Len(Format(MyNumber, "0")))&Format(MyNumber, "0")

Any help? John

Graham Mandeno said:
Five spaces followed by a numeric value? Try:
" " & MyValue

This may not give you what you want if the value is, say, greater than 9,
but then you do not have a good history for expressing your questions
clearly, nor, indeed, for showing gratitude for the learned advice you do
receive.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

00Eric Clapton said:
And how I change a field with value 1 to " 1" with leading 5 empty
space and string datatype?
 
0

00Eric Clapton

I got it guys. I just wrote a script to do the conversion. Thanks


John Griffiths said:
How about ->

Space(5-Len(Format(MyNumber, "0")))&Format(MyNumber, "0")

Any help? John

Graham Mandeno said:
Five spaces followed by a numeric value? Try:
" " & MyValue

This may not give you what you want if the value is, say, greater than 9,
but then you do not have a good history for expressing your questions
clearly, nor, indeed, for showing gratitude for the learned advice you do
receive.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

00Eric Clapton said:
And how I change a field with value 1 to " 1" with leading 5 empty
space and string datatype?


What is the function which can convert date field to string in a specific
format? Thanks.
 

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