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. Database & SysAdmin
  3. Database
  4. Database SQL

Database SQL

Scheduled Pinned Locked Moved Database
questiondatabasetutorial
7 Posts 2 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.
  • S Offline
    S Offline
    Syafiqah Zahirah
    wrote on last edited by
    #1

    Hello..i have a question about SQL Statements In my database, i have a data about datetime. The example as shown below: 2014-03-25 17:57:34.177 2014-03-25 18:01:25.280 2014-03-25 18:01:28.240 2014-03-25 18:01:33.207 This is just a few example but in my database the data is more than this.So how if i want to display the data from 30 minutes ago? what is the sql statement should I use?

    P 1 Reply Last reply
    0
    • S Syafiqah Zahirah

      Hello..i have a question about SQL Statements In my database, i have a data about datetime. The example as shown below: 2014-03-25 17:57:34.177 2014-03-25 18:01:25.280 2014-03-25 18:01:28.240 2014-03-25 18:01:33.207 This is just a few example but in my database the data is more than this.So how if i want to display the data from 30 minutes ago? what is the sql statement should I use?

      P Offline
      P Offline
      Peter Leow
      wrote on last edited by
      #2

      SELECT * FROM tablename WHERE datefield > DateADD(mi, -30, Current_TimeStamp)

      S 1 Reply Last reply
      0
      • P Peter Leow

        SELECT * FROM tablename WHERE datefield > DateADD(mi, -30, Current_TimeStamp)

        S Offline
        S Offline
        Syafiqah Zahirah
        wrote on last edited by
        #3

        tq :) and if i want to show from 1 hours is it like this SELECT * FROM tablename WHERE datefield > DateADD(mi, -60, Current_TimeStamp)?

        P 1 Reply Last reply
        0
        • S Syafiqah Zahirah

          tq :) and if i want to show from 1 hours is it like this SELECT * FROM tablename WHERE datefield > DateADD(mi, -60, Current_TimeStamp)?

          P Offline
          P Offline
          Peter Leow
          wrote on last edited by
          #4

          Yes.

          S 2 Replies Last reply
          0
          • P Peter Leow

            Yes.

            S Offline
            S Offline
            Syafiqah Zahirah
            wrote on last edited by
            #5

            tqvm for helping me :)

            1 Reply Last reply
            0
            • P Peter Leow

              Yes.

              S Offline
              S Offline
              Syafiqah Zahirah
              wrote on last edited by
              #6

              Hye peter, this code seems did'nt work..when I execute this SQL to the database directly, it will show no result :(

              P 1 Reply Last reply
              0
              • S Syafiqah Zahirah

                Hye peter, this code seems did'nt work..when I execute this SQL to the database directly, it will show no result :(

                P Offline
                P Offline
                Peter Leow
                wrote on last edited by
                #7

                Seeing is believing. try this: http://sqlfiddle.com/#!3/1fa93/13028

                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