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. Problem in inserting date for datetime field

Problem in inserting date for datetime field

Scheduled Pinned Locked Moved Database
databasehelpcsharpasp-netsql-server
7 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.
  • P Offline
    P Offline
    potlakayala
    wrote on last edited by
    #1

    I am inserting a row into database from asp.net. Below is the command i had given: insert_cmd = string.Format("Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD',14/08/2007,30,'Medium')"); The date i had given in the command is 14/08/2007, but when I check the table data in SQL server the date is displayed as ---- 1/1/1900 12:00:00 AM Please help me out... :(

    Sailaja

    R O 2 Replies Last reply
    0
    • P potlakayala

      I am inserting a row into database from asp.net. Below is the command i had given: insert_cmd = string.Format("Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD',14/08/2007,30,'Medium')"); The date i had given in the command is 14/08/2007, but when I check the table data in SQL server the date is displayed as ---- 1/1/1900 12:00:00 AM Please help me out... :(

      Sailaja

      R Offline
      R Offline
      Rami Said Abd Alhalim
      wrote on last edited by
      #2

      this problem maybe cause format date if you need sure that set in command this date solve: insert_cmd = string.Format("Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD',08/14/2007,30,'Medium')");

      P 1 Reply Last reply
      0
      • R Rami Said Abd Alhalim

        this problem maybe cause format date if you need sure that set in command this date solve: insert_cmd = string.Format("Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD',08/14/2007,30,'Medium')");

        P Offline
        P Offline
        potlakayala
        wrote on last edited by
        #3

        Said could you plz tell me how to do that as i dnt know. i'm new to sql :(

        Sailaja

        1 Reply Last reply
        0
        • P potlakayala

          I am inserting a row into database from asp.net. Below is the command i had given: insert_cmd = string.Format("Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD',14/08/2007,30,'Medium')"); The date i had given in the command is 14/08/2007, but when I check the table data in SQL server the date is displayed as ---- 1/1/1900 12:00:00 AM Please help me out... :(

          Sailaja

          O Offline
          O Offline
          okdeshpande
          wrote on last edited by
          #4

          Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD','2007-8-11',30,'Medium' In VB u have format function. U can use this function to format the date. i.e. YYYY-MM-DD format.

          P 1 Reply Last reply
          0
          • O okdeshpande

            Insert into CreateTask(AssignedTo,AssignedDate,EstimatedEfforts,Priority) values ('ABCD','2007-8-11',30,'Medium' In VB u have format function. U can use this function to format the date. i.e. YYYY-MM-DD format.

            P Offline
            P Offline
            potlakayala
            wrote on last edited by
            #5

            thx pande... the code worked correctly if I give the date in single quotes but am not getting the current system time in it.. :( its displayed as: 8/14/2007 12:00:00 AM

            Sailaja

            P 1 Reply Last reply
            0
            • P potlakayala

              thx pande... the code worked correctly if I give the date in single quotes but am not getting the current system time in it.. :( its displayed as: 8/14/2007 12:00:00 AM

              Sailaja

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              If you want to insert the current date and time, use the Getdate() function. It's a Sql Server function that returns the current date and time. For instance: insert into myTable(CurrentDate) values (GetDate());

              Deja View - the feeling that you've seen this post before.

              P 1 Reply Last reply
              0
              • P Pete OHanlon

                If you want to insert the current date and time, use the Getdate() function. It's a Sql Server function that returns the current date and time. For instance: insert into myTable(CurrentDate) values (GetDate());

                Deja View - the feeling that you've seen this post before.

                P Offline
                P Offline
                potlakayala
                wrote on last edited by
                #7

                my problem has been solved. thank u so much... :rose:

                Sailaja

                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