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. how format string

how format string

Scheduled Pinned Locked Moved ASP.NET
wpfwcf
5 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.
  • J Offline
    J Offline
    jason_mf
    wrote on last edited by
    #1

    I want to format date like "yyyy-mm-dd" when binding, but it can't like this "<%# Bind("Birthday","{yyyy-mm-dd}") %>"

    H C 2 Replies Last reply
    0
    • J jason_mf

      I want to format date like "yyyy-mm-dd" when binding, but it can't like this "<%# Bind("Birthday","{yyyy-mm-dd}") %>"

      H Offline
      H Offline
      Harini N K
      wrote on last edited by
      #2

      Hi Are you binding data from database? You can do it in SQL Query using the convert() function as given below: SELECT CONVERT(NVARCHAR(10),Birthday,121) AS Birthday FROM Table1

      Harini

      J 1 Reply Last reply
      0
      • H Harini N K

        Hi Are you binding data from database? You can do it in SQL Query using the convert() function as given below: SELECT CONVERT(NVARCHAR(10),Birthday,121) AS Birthday FROM Table1

        Harini

        J Offline
        J Offline
        jason_mf
        wrote on last edited by
        #3

        It can not be formatted in asp.net? if it can ,I want to learning.

        H 1 Reply Last reply
        0
        • J jason_mf

          It can not be formatted in asp.net? if it can ,I want to learning.

          H Offline
          H Offline
          Harini N K
          wrote on last edited by
          #4

          Then try this when binding data: DateTime DtmDate = DateTime.Now; System.Globalization.DateTimeFormatInfo dfi = new System.Globalization.DateTimeFormatInfo(); dfi.ShortDatePattern = "yyyy-MM-dd"; Response.Write(DtmDate.ToString("d", dfi));

          Harini

          modified on Wednesday, April 30, 2008 1:35 AM

          1 Reply Last reply
          0
          • J jason_mf

            I want to format date like "yyyy-mm-dd" when binding, but it can't like this "<%# Bind("Birthday","{yyyy-mm-dd}") %>"

            C Offline
            C Offline
            ChrisKo 0
            wrote on last edited by
            #5

            <%# Eval("Birthday", "{0:yyy-mm-dd}") %>

            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