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

Format Date Problem

Status
Not open for further replies.

amal1973

Technical User
Jul 31, 2001
131
US
I have a date column in table that was imported as text Ex: 20020705. That reads the fifth of July 2002. I am tiring to have it look like this format in the column. 05/07/2002. JI have tried Cdate, DateSerial. But with no luck L appreciate any help.
 
If they are always 8 digits, then you should be able to use something like:

strDate=range("A5") 'to convert the date in A5
iDay=val(mid(strDate,7))
iMon=val(mid(strDate,5,2))
iYear=val(left(strDate,4))
range("A5")=dateserial(iYear,iMon,iDay)
range("A5").numberformat="dd/mm/yyyy"

You can put this code inside a loop that tackles all of your afflicted cells one by one.
Rob
[flowerface]
 
thanks .. could you tell me how can i do it in a record set. i am using access 2000 .thanks
 
Try an update query... I created a small database with five records in one column and an empty column waiting for the converted output. ImportData was the column with the data and ConvertData was the empty 'receptacle'. On the Query tab I designed a new query, added my table, clicked on both fields to add them to the design grid, then selected "UPDATE QUERY" from the Query menu item. On the third line of the design grid under ConvertData I typed:

=Mid([importdata],5,2) & "/" & Right([importdata],2) & "/" & Left([importdata],4)

When I ran the query it converted entries like 19990807 under ImportData to 08/07/1999 under ConvertData.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top