Results 1 to 9 of 9

Thread: [RESOLVED] How to Convert String 111007 to date 11/oct/07 ?

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [RESOLVED] How to Convert String 111007 to date 11/oct/07 ?

    Hi All,

    Anyone here please help me convery string value 111007 to date Data Type :11/oct/07

    Thanks in Advance


    NuFLaVoRs
    Last edited by nUflAvOrS; Oct 22nd, 2007 at 05:30 AM.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: How to Convert String 111007 to date 11/oct/07 ?

    I was solved the problem

    This is my Solution, does anyone got better solution ?
    Please post to let me know.
    Thanks ya

    vb Code:
    1. Dim CdateVal As Date
    2. Dim StrVal As String
    3.  
    4. StrVal = "111007"
    5.  
    6. CdateVal = DateSerial(Mid(StrVal, 5, 2), Mid(StrVal, 3, 2), Mid(StrVal, 1, 2))
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  3. #3
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: How to Convert String 111007 to date 11/oct/07 ?

    Quote Originally Posted by nUflAvOrS
    Hi All,

    Anyone here please help me convery string value 111007 to date Data Type :11/oct/07

    Thanks in Advance


    NuFLaVoRs
    Code:
        Dim dm As String, dt As Date
        dm = "111007"
        dt = Left(dm, 2) & "-" & Mid(dm, 3, 2) & "-" & Mid(dm, 5)
        dt = Format("11-10-07", "dd/mmm/yyyy")
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?

    Thanks your solution,

    I appreciated your help ^^
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?

    if your date doesn't have to be a date variable, you could use the format$ command
    newstring$ = format$(olddate, "dd/mmm/yy")
    i am currently reinstalling OS and i don't have vb installed right now so i can't remember for sure if it has to be converted to a long first.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?

    Dear Sir Load Orwell ,
    I had tried the solution you were provided, it return 04/Dec/03
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to Convert String 111007 to date 11/oct/07 ?

    Anyone here please help me convery string value 111007 to date Data Type :11/oct/07
    a return value from format is not a date data type, a date data type is a date value, that is displayed as the setting in system locale (or a formatted string)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: How to Convert String 111007 to date 11/oct/07 ?

    Your own solution is the best, as long as the string is always in this format.

    Any output from the Format function is a string, and when assigned to a date variable, the output is dependent on you local settings. This is not acceptable.
    Frans

  9. #9

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: How to Convert String 111007 to date 11/oct/07 ?

    Thx westconn1 and Frans C.
    The Theory help me a lot...
    I will mark this thread resolved.
    Thanks you...
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width