date to string convert function

  • Thread starter Thread starter 00Eric Clapton
  • Start date Start date
0

00Eric Clapton

What is the function which can convert date field to string in a specific
format? Thanks.
 
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.
 
Actually, a field value 7/7/05 and how do I change it to 07072005 as a
string? Thanks.
 
And how I change a field with value 1 to " 1" with leading 5 empty space
and string datatype?
 
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...
 
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.
 
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?
 
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.
 
Back
Top