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. Web Development
  3. ASP.NET
  4. Inserting Only time into SQL db

Inserting Only time into SQL db

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
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.
  • D Offline
    D Offline
    deepseeindeepsy
    wrote on last edited by
    #1

    Hello, I want to insert only time into SQL. I have datetime field in database & also have taken datetime picker (ew) on the page. How it can be done? Please help me.. Thanx.. :)

    C N N 3 Replies Last reply
    0
    • D deepseeindeepsy

      Hello, I want to insert only time into SQL. I have datetime field in database & also have taken datetime picker (ew) on the page. How it can be done? Please help me.. Thanx.. :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I'm not sure if there's a time field in SQL. If there's not, just set the date to always be the same, and ignore it and only use the time portion.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      D 1 Reply Last reply
      0
      • D deepseeindeepsy

        Hello, I want to insert only time into SQL. I have datetime field in database & also have taken datetime picker (ew) on the page. How it can be done? Please help me.. Thanx.. :)

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        deepseeindeepsy wrote:

        I want to insert only time into SQL

        You don't have to do that. Use datetime only and when you read, use the functions provided by SQL server to get only time.

        Best wishes, Navaneeth

        D 1 Reply Last reply
        0
        • N N a v a n e e t h

          deepseeindeepsy wrote:

          I want to insert only time into SQL

          You don't have to do that. Use datetime only and when you read, use the functions provided by SQL server to get only time.

          Best wishes, Navaneeth

          D Offline
          D Offline
          deepseeindeepsy
          wrote on last edited by
          #4

          Sir, Which functions to use ? If I inserted it using nvarchar field in db, then its OK & done bt Will it affect when working on report making? Thanx.. :)

          C 1 Reply Last reply
          0
          • D deepseeindeepsy

            Sir, Which functions to use ? If I inserted it using nvarchar field in db, then its OK & done bt Will it affect when working on report making? Thanx.. :)

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            deepseeindeepsy wrote:

            If I inserted it using nvarchar field in db

            That would be utterly retarded, because you'd lose the ability to work with it as a time. This was my first google hit[^]. Was that so hard ? You can return just the time portion as a string from a datetime in the database, which is what was being suggested, use the functions in SQL Server to get back just the time, even if you store a datetime.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            1 Reply Last reply
            0
            • C Christian Graus

              I'm not sure if there's a time field in SQL. If there's not, just set the date to always be the same, and ignore it and only use the time portion.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              D Offline
              D Offline
              deepseeindeepsy
              wrote on last edited by
              #6

              Sir, I used the timepicker from EW & have written the statement as objData.AddParameter("InTime", tpInTime.SelectedTime); Here, tpInTime.SelectedTime has datetime as return value which is same in db. Even its not fare. Thanx Sir. :)

              1 Reply Last reply
              0
              • D deepseeindeepsy

                Hello, I want to insert only time into SQL. I have datetime field in database & also have taken datetime picker (ew) on the page. How it can be done? Please help me.. Thanx.. :)

                N Offline
                N Offline
                Nisha Agrawal
                wrote on last edited by
                #7

                In SQL Server 2008, there is Time Data Type so that you can insert only time value there.

                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