View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Date Conversion Help

MyDate = "##20090520123345"
MyYear = Mid(MyDate, 3, 4)
MyMonth = Mid(MyDate, 7, 2)
MyDay = Mid(MyDate, 9, 2)
MyHour = Mid(MyDate, 11, 2)
MyMinute = Mid(MyDate, 13, 2)
MySecond = Mid(MyDate, 15, 2)
Mytime = DateSerial(MyYear, MyMonth, MyDay)
Mytime = Mytime + TimeSerial(MyHour, MyMinute, MySecond)


"Saucer Man" wrote:

I have a macro which imports a date into one of my excel cells from a .csv
file in a strange format. For example, if the date is 5-20-09, it is
imported in this format...

##20090520123345

I want the macro to change it to...

05/20/09

Currently I am searching the cell and if I find the XX in the first two
positions, I am just replacing the whole string with DATE. The problem is
that the date might be a date other than today.

How can I manipulate and truncate the string once I find the entries that
start with XX? The numbers 12345 in the above example are not constant.

--
Thanks!