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. General Programming
  3. C#
  4. Need date formate like yyyy-MM-dd with time like "2008-07-08 20:24:14" in Excel

Need date formate like yyyy-MM-dd with time like "2008-07-08 20:24:14" in Excel

Scheduled Pinned Locked Moved C#
regexhelpquestion
3 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.
  • A Offline
    A Offline
    attalurisubbu
    wrote on last edited by
    #1

    Hi all, As per my requirement, while displaying date (i.e audit column) in datagrid is coming fine but same column while displaying in excel formate it is displaying as "2008-07-08" unable to get this (2008-07-08 20:24:14) formate i am using the following code sbrHTML.Append(";.premium { mso-number-format:$\\#\\,\\#\\#0\\.00;} .ogDate {mso-ignore:padding;mso-generic-font-family:auto;mso-font-charset:0;mso-number-format:yyyy-MM-dd;mso-background-source:auto;mso-pattern:auto;} ;"); then i am applying style for audit like the following sbrHTML.Append(";" + (sqlDatareader.IsDBNull(columnIndex) ? "" : sqlDatareader["AUDIT_DATE"].ToString() + ";")); ogDate For the above stmt i am able to get only this formate "2008-07-08" but i need to include time also. Could any one help me in mso-number-formate: to get date formate like "2008-07-08 20:24:14" thanks, eswar.

    P 0 2 Replies Last reply
    0
    • A attalurisubbu

      Hi all, As per my requirement, while displaying date (i.e audit column) in datagrid is coming fine but same column while displaying in excel formate it is displaying as "2008-07-08" unable to get this (2008-07-08 20:24:14) formate i am using the following code sbrHTML.Append(";.premium { mso-number-format:$\\#\\,\\#\\#0\\.00;} .ogDate {mso-ignore:padding;mso-generic-font-family:auto;mso-font-charset:0;mso-number-format:yyyy-MM-dd;mso-background-source:auto;mso-pattern:auto;} ;"); then i am applying style for audit like the following sbrHTML.Append(";" + (sqlDatareader.IsDBNull(columnIndex) ? "" : sqlDatareader["AUDIT_DATE"].ToString() + ";")); ogDate For the above stmt i am able to get only this formate "2008-07-08" but i need to include time also. Could any one help me in mso-number-formate: to get date formate like "2008-07-08 20:24:14" thanks, eswar.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      In Excel you can format the cell with a Custom format of yyyy-mm-dd hh:mm:ss or as a Date with International (ISO) locale. How you'd set that via C# I don't know.

      1 Reply Last reply
      0
      • A attalurisubbu

        Hi all, As per my requirement, while displaying date (i.e audit column) in datagrid is coming fine but same column while displaying in excel formate it is displaying as "2008-07-08" unable to get this (2008-07-08 20:24:14) formate i am using the following code sbrHTML.Append(";.premium { mso-number-format:$\\#\\,\\#\\#0\\.00;} .ogDate {mso-ignore:padding;mso-generic-font-family:auto;mso-font-charset:0;mso-number-format:yyyy-MM-dd;mso-background-source:auto;mso-pattern:auto;} ;"); then i am applying style for audit like the following sbrHTML.Append(";" + (sqlDatareader.IsDBNull(columnIndex) ? "" : sqlDatareader["AUDIT_DATE"].ToString() + ";")); ogDate For the above stmt i am able to get only this formate "2008-07-08" but i need to include time also. Could any one help me in mso-number-formate: to get date formate like "2008-07-08 20:24:14" thanks, eswar.

        0 Offline
        0 Offline
        0x3c0
        wrote on last edited by
        #3

        You can use DateTime.ToString. Pass the format you want, for example yyyy-MM-dd hh:mm:ss. You'd have to hack through the documentation for more format strings information

        Between the idea And the reality Between the motion And the act Falls the Shadow

        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