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. searching betweent two dates

searching betweent two dates

Scheduled Pinned Locked Moved Database
databasealgorithmsquestion
4 Posts 4 Posters 1 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.
  • K Offline
    K Offline
    Kunal P
    wrote on last edited by
    #1

    hi i wanted to perform a search for records based on the date range specified by the user.. the input method is in mm/dd/yyyy in the webform before going to the web from i just queried the table using the query builder and it constructed a query SELECT patient.* FROM patient WHERE (Dt BETWEEN CONVERT(DATETIME, '2006-08-09 00:00:00', 102) AND CONVERT(DATETIME, '2006-09-09 00:00:00', 102)) now how do i use the same query to the webform... also how will i display the results in a gridview control.. also.. shud i create an stored procedure, by which i can make this possible thx

    Kunal

    C F M 3 Replies Last reply
    0
    • K Kunal P

      hi i wanted to perform a search for records based on the date range specified by the user.. the input method is in mm/dd/yyyy in the webform before going to the web from i just queried the table using the query builder and it constructed a query SELECT patient.* FROM patient WHERE (Dt BETWEEN CONVERT(DATETIME, '2006-08-09 00:00:00', 102) AND CONVERT(DATETIME, '2006-09-09 00:00:00', 102)) now how do i use the same query to the webform... also how will i display the results in a gridview control.. also.. shud i create an stored procedure, by which i can make this possible thx

      Kunal

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

      A stored proc is always a better idea. You can just pass a DateTime as a param to a stored proc

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • K Kunal P

        hi i wanted to perform a search for records based on the date range specified by the user.. the input method is in mm/dd/yyyy in the webform before going to the web from i just queried the table using the query builder and it constructed a query SELECT patient.* FROM patient WHERE (Dt BETWEEN CONVERT(DATETIME, '2006-08-09 00:00:00', 102) AND CONVERT(DATETIME, '2006-09-09 00:00:00', 102)) now how do i use the same query to the webform... also how will i display the results in a gridview control.. also.. shud i create an stored procedure, by which i can make this possible thx

        Kunal

        F Offline
        F Offline
        Frank Kerrigan
        wrote on last edited by
        #3

        like this create proc getrecords @StartDate datetime, @EndDate datetime AS SELECT patient.* FROM patient WHERE (Dt BETWEEN @StartDate AND @EndDate) go

        Grady Booch: I told Google to their face...what you need is some serious adult supervision. (2007 Turing lecture) http://www.frankkerrigan.com/[^]

        1 Reply Last reply
        0
        • K Kunal P

          hi i wanted to perform a search for records based on the date range specified by the user.. the input method is in mm/dd/yyyy in the webform before going to the web from i just queried the table using the query builder and it constructed a query SELECT patient.* FROM patient WHERE (Dt BETWEEN CONVERT(DATETIME, '2006-08-09 00:00:00', 102) AND CONVERT(DATETIME, '2006-09-09 00:00:00', 102)) now how do i use the same query to the webform... also how will i display the results in a gridview control.. also.. shud i create an stored procedure, by which i can make this possible thx

          Kunal

          M Offline
          M Offline
          meeram395
          wrote on last edited by
          #4

          For searching data between two dates, you can also write the query as follows: Suppose that you want to search data between 01/03/2007 and 31/103/2007 Select field1, field2, datefield from tablename where datediff(day,'01/03/2007',datefield) >= 0 and datediff(day,'31/03/2007',datefield) <=0 order by datefield

          Meeram395

          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