Date Searches in aspx
-
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
-
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
'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 )
-
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
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))"