Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Converting string "061123" into a date "23/11/06"

Can anybody help.
I've extracted a string from a file's name, the string is "061123"
When the macro is running I need it to convert this string into a date
formatted dd/mm/yy i.e "23/11/06"

I thought this would be relatively easy but apparently not: can anybody
help ?

Any help appreciated,
Jason.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Converting string "061123" into a date "23/11/06"

Try this :

myString = "061123"

myDate = CDate(Mid(myString, 5, 2) _
& "/" & Mid(myString, 3, 2) _
& "/" & Mid(myString, 1, 2))

or
mydate = DateSerial(Mid(myString, 1, 2), Mid(myString, 3, 2),
Mid(myString, 5, 2))


WhytheQ wrote:

Can anybody help.
I've extracted a string from a file's name, the string is "061123"
When the macro is running I need it to convert this string into a date
formatted dd/mm/yy i.e "23/11/06"

I thought this would be relatively easy but apparently not: can anybody
help ?

Any help appreciated,
Jason.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Converting string "061123" into a date "23/11/06"

Hi
Try

Public Sub test()
Dim myDate As String, myYear As String
Dim myMonth As String, myDay As String, myNewDate As String
myDate = "061123"
myYear = Left(myDate, 2)
myMonth = Mid(myDate, 3, 2)
myDay = Right(myDate, 2)
myNewDate = myDay & "/" & myMonth & "/" & myYear
MsgBox myNewDate
End Sub

regards
Paul

WhytheQ wrote:

Can anybody help.
I've extracted a string from a file's name, the string is "061123"
When the macro is running I need it to convert this string into a date
formatted dd/mm/yy i.e "23/11/06"

I thought this would be relatively easy but apparently not: can anybody
help ?

Any help appreciated,
Jason.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Converting string "061123" into a date "23/11/06"

thanks very much paul & andrew.

J



On Nov 24, 9:58 am, wrote:
Hi
Try

Public Sub test()
Dim myDate As String, myYear As String
Dim myMonth As String, myDay As String, myNewDate As String
myDate = "061123"
myYear = Left(myDate, 2)
myMonth = Mid(myDate, 3, 2)
myDay = Right(myDate, 2)
myNewDate = myDay & "/" & myMonth & "/" & myYear
MsgBox myNewDate
End Sub

regards
Paul



WhytheQ wrote:
Can anybody help.
I've extracted a string from a file's name, the string is "061123"
When the macro is running I need it to convert this string into a date
formatted dd/mm/yy i.e "23/11/06"


I thought this would be relatively easy but apparently not: can anybody
help ?


Any help appreciated,
Jason.- Hide quoted text -- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"