DateTime string formatting for Oracle db?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sherifffruitfly

    DateTime string formatting for Oracle db?

    Hi,

    God I hate datetime string formatting...

    How do I get a string of the form "04-Oct-2006", for example, from a
    DateTime object?

    Thanks a jillion,

    cdj

  • Wilfried Mestdagh

    #2
    Re: DateTime string formatting for Oracle db?

    Hi,

    date.ToString(" dd-MMM-yyyy");

    --
    rgds, Wilfried [MapPoint MVP]


    sherifffruitfly wrote:
    Hi,
    >
    God I hate datetime string formatting...
    >
    How do I get a string of the form "04-Oct-2006", for example, from a
    DateTime object?
    >
    Thanks a jillion,
    >
    cdj
    >

    Comment

    • Michael Nemtsev

      #3
      Re: DateTime string formatting for Oracle db?

      Hello sherifffruitfly ,

      Console.WriteLi ne(DateTime.Now .ToString("dd-MMM-yy"));

      sHi,
      s>
      sGod I hate datetime string formatting...
      s>
      sHow do I get a string of the form "04-Oct-2006", for example, from a
      sDateTime object?
      s>
      sThanks a jillion,
      s>
      scdj
      s>
      ---
      WBR,
      Michael Nemtsev :: blog: http://spaces.live.com/laflour

      "At times one remains faithful to a cause only because its opponents do not
      cease to be insipid." (c) Friedrich Nietzsche


      Comment

      • sherifffruitfly

        #4
        Re: DateTime string formatting for Oracle db?


        Wilfried Mestdagh wrote:
        Hi,
        >
        date.ToString(" dd-MMM-yyyy");
        dammit all to hell - I coulda SWORN I tried that and it didn't work.
        lol!

        Guess I didn't - thanks!

        cdj

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: DateTime string formatting for Oracle db?

          sherifffruitfly <sherifffruitfl y@gmail.comwrot e:
          God I hate datetime string formatting...
          >
          How do I get a string of the form "04-Oct-2006", for example, from a
          DateTime object?
          From your subject line, it *sounds* like you're trying to write a SQL
          statement with the literal value in it. It's a *much* better idea to
          use a parameterised SQL statement so that you don't need to do
          formatting, escaping etc.

          --
          Jon Skeet - <skeet@pobox.co m>
          http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
          If replying to the group, please do not mail me too

          Comment

          • sherifffruitfly

            #6
            Re: DateTime string formatting for Oracle db?


            Jon wrote:
            sherifffruitfly <sherifffruitfl y@gmail.comwrot e:
            God I hate datetime string formatting...

            How do I get a string of the form "04-Oct-2006", for example, from a
            DateTime object?
            >
            From your subject line, it *sounds* like you're trying to write a SQL
            statement with the literal value in it. It's a *much* better idea to
            use a parameterised SQL statement so that you don't need to do
            formatting, escaping etc.
            >
            That sounds lovely. If only I knew what it meant - lol!

            I'm using the Oracle .net data provider ado.net stuff. It seems
            perfectly happy translating DataSet-string-dates into bonafide
            Oracle-date-dates, so where's the harm?

            If you'll give me detail about the approach you're talking about, I'm
            more than happy to give it a whirl....

            Thanks for the idea,

            cdj

            Comment

            • Jon Skeet [C# MVP]

              #7
              Re: DateTime string formatting for Oracle db?

              sherifffruitfly <sherifffruitfl y@gmail.comwrot e:
              From your subject line, it *sounds* like you're trying to write a SQL
              statement with the literal value in it. It's a *much* better idea to
              use a parameterised SQL statement so that you don't need to do
              formatting, escaping etc.
              >
              That sounds lovely. If only I knew what it meant - lol!
              >
              I'm using the Oracle .net data provider ado.net stuff. It seems
              perfectly happy translating DataSet-string-dates into bonafide
              Oracle-date-dates, so where's the harm?
              a) It means you need to get it right
              b) It makes your code harder to port to other providers
              c) If you do the same thing with other data types (and particularly
              strings) you leave yourself open to SQL injection attacks if you're not
              careful
              If you'll give me detail about the approach you're talking about, I'm
              more than happy to give it a whirl....
              See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
              If that doesn't help, I'm sure the ADO.NET newsgroup will be happy to
              provide more details :)

              --
              Jon Skeet - <skeet@pobox.co m>
              http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
              If replying to the group, please do not mail me too

              Comment

              • sherifffruitfly

                #8
                Re: DateTime string formatting for Oracle db?


                Jon wrote:
                sherifffruitfly <sherifffruitfl y@gmail.comwrot e:
                If you'll give me detail about the approach you're talking about, I'm
                more than happy to give it a whirl....
                >
                See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
                If that doesn't help, I'm sure the ADO.NET newsgroup will be happy to
                provide more details :)
                Oooh - there's an ado.net group! See ya!

                Thanks for the overview-idea-page!

                lol :)

                cdj

                Comment

                Working...