convert text to Date..

  • Thread starter mls via AccessMonster.com
  • Start date
M

mls via AccessMonster.com

How can I convert my text field ( read from CSV file) to show the Date as
01/05/2010 instead of long date..
Can I use CDate()?

rundate =Tuesday, January 05, 2010 12:45:11

I used the following..
'Dim date_tested As Date
'date_tested = Format(rundate, "Short Date")
'date_tested = Format(rundate, "mm/dd/yyyy")



Thank you
 
J

John W. Vinson

How can I convert my text field ( read from CSV file) to show the Date as
01/05/2010 instead of long date..
Can I use CDate()?

rundate =Tuesday, January 05, 2010 12:45:11

I used the following..
'Dim date_tested As Date
'date_tested = Format(rundate, "Short Date")
'date_tested = Format(rundate, "mm/dd/yyyy")



Thank you

Interesting. After some exploration, I found that the day name is messing it
up. Datevalue("Tuesday, January 05, 2010 12:45:11") gives an error, but
Datevalue("January 05, 2010 12:45:11") returns 1/5/2010.

Try Datevalue(Mid([rundate], InStr([rundate], ",") + 2)

This will return an Access Date/Time value which can be formatted any way you
choose.
 
M

mls via AccessMonster.com

Thanks John this works perfect. Just one closing parentheseis is missing..
Datevalue(Mid([rundate], InStr([rundate], ",") + 2) )
How can I convert my text field ( read from CSV file) to show the Date as
01/05/2010 instead of long date..
[quoted text clipped - 8 lines]
Thank you

Interesting. After some exploration, I found that the day name is messing it
up. Datevalue("Tuesday, January 05, 2010 12:45:11") gives an error, but
Datevalue("January 05, 2010 12:45:11") returns 1/5/2010.

Try Datevalue(Mid([rundate], InStr([rundate], ",") + 2)

This will return an Access Date/Time value which can be formatted any way you
choose.
 

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