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. Convert datetime to date

Convert datetime to date

Scheduled Pinned Locked Moved ASP.NET
design
3 Posts 2 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.
  • M Offline
    M Offline
    mahichandu
    wrote on last edited by
    #1

    Hi.. i want to convert datatime format to Date...i want to display On UI only date... I am using below method its not working for me... can anyone suggest me.. public static String GetShortDate(String sDateTimeValue) { return String.Format("{0:dd/MM/yy}", sDateTimeValue.ToString()); }

    M 1 Reply Last reply
    0
    • M mahichandu

      Hi.. i want to convert datatime format to Date...i want to display On UI only date... I am using below method its not working for me... can anyone suggest me.. public static String GetShortDate(String sDateTimeValue) { return String.Format("{0:dd/MM/yy}", sDateTimeValue.ToString()); }

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      public static String GetShortDate(String sDateTimeValue)
      {
      DateTime _date = DateTime.Parse(sDateTimeValue);
      return _date.ToString("d", DateTimeFormatInfo.InvariantInfo);
      }

      Have a look at the various formats here[^]

      Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      modified on Tuesday, June 23, 2009 4:09 AM

      M 1 Reply Last reply
      0
      • M Manas Bhardwaj

        public static String GetShortDate(String sDateTimeValue)
        {
        DateTime _date = DateTime.Parse(sDateTimeValue);
        return _date.ToString("d", DateTimeFormatInfo.InvariantInfo);
        }

        Have a look at the various formats here[^]

        Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        modified on Tuesday, June 23, 2009 4:09 AM

        M Offline
        M Offline
        mahichandu
        wrote on last edited by
        #3

        Hey..i tried with above method..i followed other methods also which you send me ..i,e very good link for beginners like me....eventhough i couldn't resolve that issue.. its throwing exception error like below.. FORMAT EXCEPTION UNHANDLED BY USERCODE... converting from string to datetime parse the string to take the date before putting each variable datetime object into How can i resolve ???

        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