PC Review


Reply
Thread Tools Rate Thread

Converting string "061123" into a date "23/11/06"

 
 
WhytheQ
Guest
Posts: n/a
 
      24th Nov 2006
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.

 
Reply With Quote
 
 
 
 
Andrew Taylor
Guest
Posts: n/a
 
      24th Nov 2006
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.


 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      24th Nov 2006
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.


 
Reply With Quote
 
WhytheQ
Guest
Posts: n/a
 
      24th Nov 2006
thanks very much paul & andrew.

J



On Nov 24, 9:58 am, paul.robin...@it-tallaght.ie 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
Converting "uppercase" string data to "lower case" in CSV file akarui.tomodachi@gmail.com Microsoft Excel Misc 2 12th Aug 2008 08:36 PM
Converting "yyyymmdd" date string into "dd monthname yyyy" format stainless Microsoft C# .NET 2 31st Jan 2008 06:28 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:40 AM.