Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Converting "uppercase" string data to "lower case" in CSV file | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |