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
  1. Home
  2. Web Development
  3. ASP.NET
  4. DateTime Problem

DateTime Problem

Scheduled Pinned Locked Moved ASP.NET
helpdesigntutorial
6 Posts 5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

    J A D L A 5 Replies Last reply
    0
    • L Lost User

      Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

      J Offline
      J Offline
      Jamil Hallal
      wrote on last edited by
      #2

      Hi, Please use the below:

      DateTime dt = DateTime.Now;
      string strDate = dt.ToString("dd-MMMM-yyyy");

      Regards, Jamil

      1 Reply Last reply
      0
      • L Lost User

        Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

        A Offline
        A Offline
        An Ha Ja
        wrote on last edited by
        #3

        You can get the date in the required format from the database. Try this

        SELECT CONVERT(VARCHAR,GETDATE(),106)

        modified on Friday, April 30, 2010 3:34 AM

        1 Reply Last reply
        0
        • L Lost User

          Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

          D Offline
          D Offline
          Dinesh Mani
          wrote on last edited by
          #4

          I assume you want to display 5/13/2010 as 13-May-2010 and not 08-May-2010. Its very easy to do it. If you are displaying the date in a label then you are probably assigning the date value to the text property like this Label1.Text = DateTimeValue.ToString();. Now to apply formatting in this case just pass the format string as parameter to the ToString() function like this Label1.Text = DateTimeValue.ToString("dd-MMM-yyyy"); You could also use this String.Format("{0:dd-MMM-yyyy}", DateTimeValue.ToString()); NOTE - Month should be specified as "MMM" and not "mmm". For more format strings refer this page - String Format for DateTime [C#][^]

          1 Reply Last reply
          0
          • L Lost User

            Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Thanks all

            1 Reply Last reply
            0
            • L Lost User

              Hi all I am getting Date time from date base in the following format 5/13/2010 12:00:00 AM I want to display it in UI in following format 08-May-2010 can u guys please help me how to do this Thanks and regards, Amit

              A Offline
              A Offline
              Arindam Tewary
              wrote on last edited by
              #6

              Hi, use following while selecting datetype column from databse.

              select replace(convert(varchar,getdate(),106),' ','-')

              Thanks, Arindam D Tewary

              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