Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. i need date like this format (mm/dd/yyyy 10:03:44 AM) in Asp.net with c#

i need date like this format (mm/dd/yyyy 10:03:44 AM) in Asp.net with c#

Scheduled Pinned Locked Moved IT & Infrastructure
csharpasp-nethelptutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    priyamsc
    wrote on last edited by
    #1

    In my asp.net with c# application i inserted date time with the help of this (datetime.now.tostring()) in this application it gives" dd/mm/yyyy 12:03:44AM" but in sqlserver it takes "mm/dd/yy 12:03:34 Am" format.so i do know how to give that format in Asp.net application.if any one knows then help me.. Thank you,

    k.priya

    G C 2 Replies Last reply
    0
    • P priyamsc

      In my asp.net with c# application i inserted date time with the help of this (datetime.now.tostring()) in this application it gives" dd/mm/yyyy 12:03:44AM" but in sqlserver it takes "mm/dd/yy 12:03:34 Am" format.so i do know how to give that format in Asp.net application.if any one knows then help me.. Thank you,

      k.priya

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Use parametrized queries and you will not have to change date from one format to another. If you still want to change it then use the ToSring() function of DateTime structure and pass necessary format.

      Giorgi Dalakishvili #region signature my articles #endregion

      P 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        Use parametrized queries and you will not have to change date from one format to another. If you still want to change it then use the ToSring() function of DateTime structure and pass necessary format.

        Giorgi Dalakishvili #region signature my articles #endregion

        P Offline
        P Offline
        priyamsc
        wrote on last edited by
        #3

        Thank you for ur reply. i have given like this Response.Write(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss AM/PM")); the result is===>03/17/2008 01:24:48 A3/P3 and it gave A3/P3.but i need AM or PM but i need to store either AM or PM so ple help me.. and when i give mm/dd/yyyy it shows 22/17/2008 what is the difference between mm and MM sir... thank you

        k.priya

        G P 2 Replies Last reply
        0
        • P priyamsc

          Thank you for ur reply. i have given like this Response.Write(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss AM/PM")); the result is===>03/17/2008 01:24:48 A3/P3 and it gave A3/P3.but i need AM or PM but i need to store either AM or PM so ple help me.. and when i give mm/dd/yyyy it shows 22/17/2008 what is the difference between mm and MM sir... thank you

          k.priya

          G Offline
          G Offline
          Giorgi Dalakishvili
          wrote on last edited by
          #4

          priyamsc wrote:

          what is the difference between mm and MM sir...

          They hide information in the docs[^]

          Giorgi Dalakishvili #region signature my articles #endregion

          1 Reply Last reply
          0
          • P priyamsc

            Thank you for ur reply. i have given like this Response.Write(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss AM/PM")); the result is===>03/17/2008 01:24:48 A3/P3 and it gave A3/P3.but i need AM or PM but i need to store either AM or PM so ple help me.. and when i give mm/dd/yyyy it shows 22/17/2008 what is the difference between mm and MM sir... thank you

            k.priya

            P Offline
            P Offline
            priyamsc
            wrote on last edited by
            #5

            i got the answer just gave "MM/dd/yyyy hh:mm:ss"... but just give the explanation of this.... when i give mm/dd/yyyy it shows 22/17/2008 what is the difference between mm and MM ... and 03/17/2008 01:24:48 A3/P3 what is A3 when i give AM/PM..why its not coming properly...

            k.priya

            1 Reply Last reply
            0
            • P priyamsc

              In my asp.net with c# application i inserted date time with the help of this (datetime.now.tostring()) in this application it gives" dd/mm/yyyy 12:03:44AM" but in sqlserver it takes "mm/dd/yy 12:03:34 Am" format.so i do know how to give that format in Asp.net application.if any one knows then help me.. Thank you,

              k.priya

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              If you designed your DB properly, you wouldn't have this problem. Even if you found a solution using string mashing, it really doesn't change that your design is broken. Store dates in a date datatype, not as strings.

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              P 1 Reply Last reply
              0
              • C Christian Graus

                If you designed your DB properly, you wouldn't have this problem. Even if you found a solution using string mashing, it really doesn't change that your design is broken. Store dates in a date datatype, not as strings.

                Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                P Offline
                P Offline
                priyamsc
                wrote on last edited by
                #7

                Got the answer..Thanks to all ...

                k.priya

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups