convert month-year to valid date

  • Thread starter Thread starter ragtopcaddy via AccessMonster.com
  • Start date Start date
R

ragtopcaddy via AccessMonster.com

I have a text file dumped in my db that contains a date field in month-year
format. It's a string like "Apr-08" for April, 2008. If I use the cdate
function it comes out "08-Apr-2006". I'd like to end up with "Apr-2008" if
possible. I would settle for "01-Apr-2008" if necessary.
 
Nevermind, I got it:

Format(CDate("01-" & [Contract Month]),"mmm-yyyy")
I have a text file dumped in my db that contains a date field in month-year
format. It's a string like "Apr-08" for April, 2008. If I use the cdate
function it comes out "08-Apr-2006". I'd like to end up with "Apr-2008" if
possible. I would settle for "01-Apr-2008" if necessary.

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
 
If MyTextDate = "Apr-08" and you want it to get into a date field, it will
have to have a day. To get it into a date field, all you need is:
cdate("01-" & MyTextDate)
Which will make it April 1, 2008
If you want it displayed as "Apr-08", the formula below will do it for the
text.
format(cdate("01-" & MyTextDate),"mmm-yy")
Once it is in the date field in your table
format(MyDateField, "mmm-yy")
 
Klatuu,

Thanks once again for your help. As often happens, just posing the question
made me think a little deeper about a solution.

Bill R
 
Back
Top