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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a field called pubdate which

Status
Not open for further replies.

Tarbuza

Technical User
Dec 13, 2000
56
US
I have a field called pubdate which is a text field but I have date in the followin format:

December 1994

14 May 1997

1 December 1999

I want to change December into 12, May into 5 etc. So the above date should look like as follows:

12 1994
14 5 1997
1 12 1999

Thanks in advance for any helps.
 
If you need to maintain the order the dateparts from the old format to the new your request gets more complicated. However if you can have everything put into a standard format it is easy.

If IsDate(strOldDate) Then
strNewDate = Format(CDate(strOldDate), "m d yyyy")
End If


If you need to keep the order of the dateparts I would suggest something like the following:


For bytMonth = 1 To 12
strMonth = Format(bytMonth & "/1/2003", "MMMM")
intPosition = InStr(1, strOldDate, strMonth)
If intPosition > 0 Then
strNewDate = Left(strOldDate, intPosition - 1) & "1" & Right(strOldDate, Len(strOldDate) - (intPosition + Len(strMonth)) + 1)
MsgBox strNewDate
End If
Next bytMonth


Hope this works for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top