convert a custom format string back to datetime

Discussion in 'ASP .Net' started by Lynn, Sep 17, 2004.

  1. Lynn

    Lynn Guest

    Hi All,
    We all know we can use
    toString(strFormat) mothod to convert a datetime variable to a custom
    string, let say strFormat = "YYYY!MM*DD", then we can get '2004!09*18', how
    can I get convert the string back to datetime based on the specific format
    'YYYY!MM*DD'.

    Convert.todatetime method seems does not work.


    Thanks a lot.


    Lynn
     
    Lynn, Sep 17, 2004
    #1
    1. Advertising

  2. Dim d As Date = #9/18/2004#
    Dim s As String
    s = d.ToString("yyyy!MM*dd")
    Console.WriteLine(s)
    Dim d2 As Date
    d2 = Date.ParseExact(s, "yyyy!MM*dd", New
    System.Globalization.DateTimeFormatInfo)
    Console.WriteLine(d2)

    --
    Jonathan Allen


    "Lynn" <> wrote in message
    news:...
    > Hi All,
    > We all know we can use
    > toString(strFormat) mothod to convert a datetime variable to a custom
    > string, let say strFormat = "YYYY!MM*DD", then we can get '2004!09*18',

    how
    > can I get convert the string back to datetime based on the specific format
    > 'YYYY!MM*DD'.
    >
    > Convert.todatetime method seems does not work.
    >
    >
    > Thanks a lot.
    >
    >
    > Lynn
    >
    >
     
    Jonathan Allen, Sep 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    712
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    538
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    392
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    338
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    762
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page