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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Date format in ACCESS database

Date format in ACCESS database

Scheduled Pinned Locked Moved Database
databasecsharpcsshelpquestion
9 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.
  • J Offline
    J Offline
    Johnkokk
    wrote on last edited by
    #1

    Ok, here is a silly one. I have a ms access database that i want to manipulate through a datagridview in my VB .net app. I have defined the appropriate field in the database as DATE/TIME, because i will make date filtering on the records through sql in my app. Now when i add any record through my app, i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid. I DO NOT want the time part. Is this doable or i am stuck with it ? Thanks

    L T L 3 Replies Last reply
    0
    • J Johnkokk

      Ok, here is a silly one. I have a ms access database that i want to manipulate through a datagridview in my VB .net app. I have defined the appropriate field in the database as DATE/TIME, because i will make date filtering on the records through sql in my app. Now when i add any record through my app, i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid. I DO NOT want the time part. Is this doable or i am stuck with it ? Thanks

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

      Johnkokk wrote:

      i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid.

      Go to the offending table and open it in the design-view. Click on the DateTime-field and go to the properties. There's a Format property that controls how the data of this particular column is formatted.

      I are Troll :suss:

      L J 2 Replies Last reply
      0
      • J Johnkokk

        Ok, here is a silly one. I have a ms access database that i want to manipulate through a datagridview in my VB .net app. I have defined the appropriate field in the database as DATE/TIME, because i will make date filtering on the records through sql in my app. Now when i add any record through my app, i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid. I DO NOT want the time part. Is this doable or i am stuck with it ? Thanks

        T Offline
        T Offline
        thatraja
        wrote on last edited by
        #3

        you can solve it by two ways. 1. Using the date column datatype's format property in Access database.(various formats like General Date, Long Date, Medium Date, Short Date, Long Time, Medium Time, Short Time) 2. using the DataFormatString property of bound column in gridview. (examples: DataFormatString="{0:MM-dd-yyyy}", DataFormatString="{0:MMM dd, yyyy}", DataFormatString="{0:ddd MM, yyyy}", etc )

        thatraja


        Tips/Tricks|Brainbench certifications

        J 1 Reply Last reply
        0
        • L Lost User

          Johnkokk wrote:

          i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid.

          Go to the offending table and open it in the design-view. Click on the DateTime-field and go to the properties. There's a Format property that controls how the data of this particular column is formatted.

          I are Troll :suss:

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

          :confused: I would assign the responsibilities to the right parties: let the database hold the data and not worry about formatting, and let the application take care of the formatting; in this case, tell the DGV what format is to be used.

          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.


          L 1 Reply Last reply
          0
          • L Lost User

            Johnkokk wrote:

            i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid.

            Go to the offending table and open it in the design-view. Click on the DateTime-field and go to the properties. There's a Format property that controls how the data of this particular column is formatted.

            I are Troll :suss:

            J Offline
            J Offline
            Johnkokk
            wrote on last edited by
            #5

            I've already tried setting the formating in the database field. It doesn't work

            1 Reply Last reply
            0
            • J Johnkokk

              Ok, here is a silly one. I have a ms access database that i want to manipulate through a datagridview in my VB .net app. I have defined the appropriate field in the database as DATE/TIME, because i will make date filtering on the records through sql in my app. Now when i add any record through my app, i always get a date format like 17/2/2010 0:00:00 in the datagridview, obiously because this is the format of the access database which is databound to the grid. I DO NOT want the time part. Is this doable or i am stuck with it ? Thanks

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

              Hi, you can set the formatting specification for each individual column of a DataGridView. Here is a C# example:

              dgv.Columns[1].DefaultCellStyle.Format="dd MMM yyyy";

              which works fine as long as the field bound to that column is a DateTime (and not a string!) :)

              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
              • T thatraja

                you can solve it by two ways. 1. Using the date column datatype's format property in Access database.(various formats like General Date, Long Date, Medium Date, Short Date, Long Time, Medium Time, Short Time) 2. using the DataFormatString property of bound column in gridview. (examples: DataFormatString="{0:MM-dd-yyyy}", DataFormatString="{0:MMM dd, yyyy}", DataFormatString="{0:ddd MM, yyyy}", etc )

                thatraja


                Tips/Tricks|Brainbench certifications

                J Offline
                J Offline
                Johnkokk
                wrote on last edited by
                #7

                <b>2. using the DataFormatString property of bound column in gridview. (examples: DataFormatString="{0:MM-dd-yyyy}", DataFormatString="{0:MMM dd, yyyy}", DataFormatString="{0:ddd MM, yyyy}", etc )</b> That worked, thanks

                1 Reply Last reply
                0
                • L Luc Pattyn

                  :confused: I would assign the responsibilities to the right parties: let the database hold the data and not worry about formatting, and let the application take care of the formatting; in this case, tell the DGV what format is to be used.

                  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.


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

                  +5, and goodmorning; You're right. The native grid in Access 2007 doesn't support that, but if it's a VB.NET application than he's using a DataGridView - and not a grid on a native Access-form :)

                  I are Troll :suss:

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    +5, and goodmorning; You're right. The native grid in Access 2007 doesn't support that, but if it's a VB.NET application than he's using a DataGridView - and not a grid on a native Access-form :)

                    I are Troll :suss:

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

                    Good morning Sir to you too. :)

                    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