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. Date Searches in aspx

Date Searches in aspx

Scheduled Pinned Locked Moved ASP.NET
databasequestioncsharpasp-netsql-server
3 Posts 3 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.
  • A Offline
    A Offline
    aransiola
    wrote on last edited by
    #1

    Im using asp.net 2.0 with sql server 2005, My date from teh web form is of teh format dd/mm/yyyy. This date when saved in SQL Server is saved as dd/mm/yyyy 00:00:00 AM or dd/mm/yyyy 00:00:00 PM. I want to construct a query from aspx using a date range. The query is not working See my Query Syntax below "Select * From table where myDate between " & Date.Parse(DateCtr1) & " And " & Date.Parse(DateCtr2) How can i save my Date from teh WebForm to include the Date And Time? t.aransiola

    C D 2 Replies Last reply
    0
    • A aransiola

      Im using asp.net 2.0 with sql server 2005, My date from teh web form is of teh format dd/mm/yyyy. This date when saved in SQL Server is saved as dd/mm/yyyy 00:00:00 AM or dd/mm/yyyy 00:00:00 PM. I want to construct a query from aspx using a date range. The query is not working See my Query Syntax below "Select * From table where myDate between " & Date.Parse(DateCtr1) & " And " & Date.Parse(DateCtr2) How can i save my Date from teh WebForm to include the Date And Time? t.aransiola

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

      'not working' probably means it loses the last day because the time is defaulting to 12:00 am. Just set the time to 11:59:59 pm on the second date you pass in, and it will work fine.

      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
      • A aransiola

        Im using asp.net 2.0 with sql server 2005, My date from teh web form is of teh format dd/mm/yyyy. This date when saved in SQL Server is saved as dd/mm/yyyy 00:00:00 AM or dd/mm/yyyy 00:00:00 PM. I want to construct a query from aspx using a date range. The query is not working See my Query Syntax below "Select * From table where myDate between " & Date.Parse(DateCtr1) & " And " & Date.Parse(DateCtr2) How can i save my Date from teh WebForm to include the Date And Time? t.aransiola

        D Offline
        D Offline
        dwatkins dirq net
        wrote on last edited by
        #3

        Are your database fields DateTimes or strings (varchars)? Assuming you are using DateTimes: "SELECT 8 FROM table WHERE (myDate >= CONVERT(DATETIME, '" & Date.Parse(DateCtr1) & "', 102)) AND (myDate <= CONVERT(DATETIME, '" & Date.Parse(DateCtr2) & "', 102))"

        Dirk Watkins

        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