DateTime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalini166
    New Member
    • Apr 2008
    • 70

    DateTime

    I used datetime datatype in my database.

    After i enter date in my textbox.The date will store into database with time also.
    I need to store only date .
    pls help me.
    It is urgent for me.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Originally posted by shalini166
    I used datetime datatype in my database.

    After i enter date in my textbox.The date will store into database with time also.
    I need to store only date .
    pls help me.
    It is urgent for me.
    What kind of Database are you using? Sql Server will always store a time with a date. You could strip the time off of the date, but the Sql Server will add a "12:00 AM" onto the date.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Just ignore the time then? Just because it stores, does not mean you have to use that part.

      Comment

      • shalini166
        New Member
        • Apr 2008
        • 70

        #4
        Thank for ur reply.

        Actually i retrieve the data from the database into datagrid.I also retrieve the date field.But it display in the datagrid with the format 4/6/08 12.00 am.
        but i need to display only date.

        Pls help me.

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          If this is a DataGrid, use the data formatting expression. You will need to manually add your columns, and in the Data Formatting Expression, you should put something like: {0:dd/MM/yyyy}
          that would give 28/5/2008 for today's date. Move the letters around to change the formatting. You can also replace the slashes with whatever delimiter you like. Google FormatString for more options.

          If you are using a gridview, the process is similar. You need to edit the column's properties, and include that formatting string in the DataFormatStrin g attribute.

          The GridView is easier to work with, in my opinion.

          Originally posted by shalini166
          Thank for ur reply.

          Actually i retrieve the data from the database into datagrid.I also retrieve the date field.But it display in the datagrid with the format 4/6/08 12.00 am.
          but i need to display only date.

          Pls help me.

          Comment

          • shalini166
            New Member
            • Apr 2008
            • 70

            #6
            thank u .i will try.

            Comment

            • malav123
              New Member
              • Feb 2008
              • 217

              #7
              Hi shalini,
              if you want to extract date at the time of display then use following in query at the place of date.....

              convert(varchar (10),insertDate ,101) as insertDate.
              for example, select convert(varchar (10),insertDate ,101) as insertDate from table...


              your problem will be solved....


              -malav..

              Comment

              • shalini166
                New Member
                • Apr 2008
                • 70

                #8
                Thank u very much.I got the answer.

                Comment

                • malav123
                  New Member
                  • Feb 2008
                  • 217

                  #9
                  Originally posted by shalini166
                  Thank u very much.I got the answer.
                  there are many codes like 101 to extract particular things from date time......

                  Comment

                  • malav123
                    New Member
                    • Feb 2008
                    • 217

                    #10
                    Originally posted by shalini166
                    Thank u very much.I got the answer.
                    And it's glad that your problem is solved....

                    Comment

                    Working...