Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text to date

Status
Not open for further replies.

eti3nne

MIS
Feb 5, 2004
102
I have dates in the format of 200804; 200712 etc meaning year 2008 month04; year 2007 month 12 etc.

How can i get these to read as Apr 2008; Dec 2007?

I need to do the conversion in sql, but if you can help me in access I might be able to tranlate the solution?
 
Hi,

This is an unambiguous conversion (not UK nor US based)
Code:
YourDat: DateSerial(Mid([YourDateString],1,4),Mid([YourDateString],5,2),Mid([YourDateString],7,2))


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Format(DateSerial(Left([YourDateField],4),Mid([YourDateField],5,2),1), "mmm yyyy")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks all for those thoughts. Unfortunately format and mid functions do not work in sql.

I have had a further thought on this... what I actually need is to convert eg '200804' into 'Apr 2008' etc, (with no '1st of the month' attached).

My post is titled 'text to date', perhaps i am approaching/describing this the wrong way; I probably need 'text to text'? - the resulting text being a date of sorts.

Any further thoughts greatfully received.

Thanks for looking.
 
And this ?
MonthName(Right(yourDatefield,2),True) & " " & Left(yourDateField,4)

BTW, which flavor of SQL ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


"Unfortunately format and mid functions do not work in sql."

What database are you coding in?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
MonthName function isn't available either.

Database is in sql ?2000.

I may have to use a lookup table or hard code a line of code for each of the months, in the DTS.

Cheers,

Steve.
 
Maybe post in Forum183 rather than an MS Access forum?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top