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. Date problem

Date problem

Scheduled Pinned Locked Moved C#
questionhelp
5 Posts 4 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
    Mogamboo_Khush_Hua
    wrote on last edited by
    #1

    Hi, I am allowing user to select datetime in datetimepicker in "dd/MM/yyyy" format but when it stores in sqlserver 2005 it store as "mm/DD/yyyy", but i want it store as "dd/MM/yyyy" format in SqlServer 2005, how can i do that OR When i filter records, it should be in "dd/MM/yyyy" format ? Regards, XYZ

    A L 2 Replies Last reply
    0
    • M Mogamboo_Khush_Hua

      Hi, I am allowing user to select datetime in datetimepicker in "dd/MM/yyyy" format but when it stores in sqlserver 2005 it store as "mm/DD/yyyy", but i want it store as "dd/MM/yyyy" format in SqlServer 2005, how can i do that OR When i filter records, it should be in "dd/MM/yyyy" format ? Regards, XYZ

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      The internal format used to store a date time has nothing to do with how it is serialized as a string. Both SQL and C# have techniques for serializing date/times. In particular, you'll want to look into DATEPART and CONVERT for SQL and ToString and String.Format for C#. The C# DateTime also has several methods that allow you to serialize to different common formats.

      [Forum Guidelines]

      C 1 Reply Last reply
      0
      • A AspDotNetDev

        The internal format used to store a date time has nothing to do with how it is serialized as a string. Both SQL and C# have techniques for serializing date/times. In particular, you'll want to look into DATEPART and CONVERT for SQL and ToString and String.Format for C#. The C# DateTime also has several methods that allow you to serialize to different common formats.

        [Forum Guidelines]

        C Offline
        C Offline
        Chetan Patel
        wrote on last edited by
        #3

        Write in SQL Select Query Select Convert(varchar(10),getdate(),103) Like this will return dd-MM-yyyy And in C# use .ToString("dd-MM-yyyy"); In grid use DataFormatString Property and make sure HTMLEncode="False" set in That column

        Best Regards, Chetan Patel

        A 1 Reply Last reply
        0
        • C Chetan Patel

          Write in SQL Select Query Select Convert(varchar(10),getdate(),103) Like this will return dd-MM-yyyy And in C# use .ToString("dd-MM-yyyy"); In grid use DataFormatString Property and make sure HTMLEncode="False" set in That column

          Best Regards, Chetan Patel

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          I already know how to do that... you might want to reply to the OP to tell him/her what you've told me. Though, to be honest, I think I gave him/her enough information already.

          [Forum Guidelines]

          1 Reply Last reply
          0
          • M Mogamboo_Khush_Hua

            Hi, I am allowing user to select datetime in datetimepicker in "dd/MM/yyyy" format but when it stores in sqlserver 2005 it store as "mm/DD/yyyy", but i want it store as "dd/MM/yyyy" format in SqlServer 2005, how can i do that OR When i filter records, it should be in "dd/MM/yyyy" format ? Regards, XYZ

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            you might want to read this[^]. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
            All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.


            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