date time formatting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QW5kcmV3?=

    date time formatting

    hi,

    my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

    however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.

    how do i convert/parse the datetime value from the datetimepicker to the sp
    datetime format ? I've tried:
    eg.
    IFormatProvider culture = new CultureInfo("en-US", true);
    DateTime dt3 = DateTime.ParseE xact("20080722 10:00:00" , "yyyyMMdd
    HH:mm:ss", culture);

    No matter what datetime format I pass in, I will always get a "dd/MM/yyyy
    HH:mm:ss" format in return, which is not what I want to get. Is my culture
    wrong ?

    Any advice is appreciated.
    Thanks in advance.

    regards,
    Andrew


  • Jan Hyde (VB MVP)

    #2
    Re: date time formatting

    Andrew <Andrew@discuss ions.microsoft. com>'s wild thoughts
    were released on Mon, 7 Jul 2008 01:51:01 -0700 bearing the
    following fruit:
    >hi,
    >
    >my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.
    >
    >however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.
    >
    >how do i convert/parse the datetime value from the datetimepicker to the sp
    >datetime format ? I've tried:
    >eg.
    >IFormatProvide r culture = new CultureInfo("en-US", true);
    >DateTime dt3 = DateTime.ParseE xact("20080722 10:00:00" , "yyyyMMdd
    >HH:mm:ss", culture);
    >
    >No matter what datetime format I pass in, I will always get a "dd/MM/yyyy
    >HH:mm:ss" format in return, which is not what I want to get. Is my culture
    >wrong ?
    >
    Store your date in the format you want in a string and pass
    that to your sp.
    --
    Jan Hyde


    Comment

    • Mihai N.

      #3
      Re: date time formatting

      my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.
      >
      however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.
      DateTimePicker. Value Property is a DateTime, no need to go thru a
      string and then parse it.


      --
      Mihai Nita [Microsoft MVP, Visual C++]
      Best internationalization practices, solving internationalization problems.

      ------------------------------------------
      Replace _year_ with _ to get the real email

      Comment

      • =?Utf-8?B?QW5kcmV3?=

        #4
        Re: date time formatting

        Hi thanks for your reply.

        The sp takes datetime in format 'yyyyMMdd HH:mm:ss'
        The datetime picket produces a value in format 'dd/MM/yyyy HH:mm:ss'
        I just modified the sp to take in a varchar(17) and cast it to a datetime
        format.

        cheers
        Andrew

        "Mihai N." wrote:
        >
        my sp takes datetime in 'yyyyMMdd HH:mm:ss' format.

        however my c# datetimepicker takes 'dd/MM/yy HH:mm:ss' format.
        >
        DateTimePicker. Value Property is a DateTime, no need to go thru a
        string and then parse it.
        >
        >
        --
        Mihai Nita [Microsoft MVP, Visual C++]
        Best internationalization practices, solving internationalization problems.

        ------------------------------------------
        Replace _year_ with _ to get the real email
        >

        Comment

        • Mihai N.

          #5
          Re: date time formatting

          The datetime picket produces a value in format 'dd/MM/yyyy HH:mm:ss'
          Make sure that the result is 'dd/MM/yyyy HH:mm:ss' even for non-US
          systems, otherwise you might have a nasty surprise later on.


          --
          Mihai Nita [Microsoft MVP, Visual C++]
          Best internationalization practices, solving internationalization problems.

          ------------------------------------------
          Replace _year_ with _ to get the real email

          Comment

          Working...