|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to create a query that returns a set of results from a table. I have used the between statement in the Criteria field of the query as;
Between [Type the beginning date:] And [Type the ending date:] However, when I type the dates into the pop-up boxes as 3/1/2004 and 3/15/2004, the results do not include 3/2-9/2004. It lists 3/1/2004 then skips to 3/10/2004 and shows dates until 3/15/2004. I need it to show all dates from the 1st through the 15th. What's wrong with this? |
|
#2
|
||||
|
||||
|
If you are using Access, then your dates in the query must be surrounded by the hash symbol (#).
|
|
#3
|
|||
|
|||
|
How should that look?
|
|
#4
|
||||
|
||||
|
|
|
#5
|
|||
|
|||
|
What I want is for the query to ask for the dates to be entered. If I type the below in, it surely won't, right? But also, when I type this into the criteria section under the date field, it returns no values when clearly there are values for this criteria inclusively.
Between "#3/1/2004#" And "#3/15/2004#" |
|
#6
|
|||
|
|||
|
In SQL Server you can format dates as 'yyyymmdd', so you can script something like:
Between '20040301' and '20040315' |
|
#7
|
|||
|
|||
|
I just did a query like this in SQL server... mine looked something like this:
SELECT col_1, col_2 FROM myTable WHERE convert (datetime, convert (varchar, myTable.Date, 101), 101) >= @param1 AND convert (datetime, convert (varchar, myTable.Date, 101), 101) <= @param2 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Between Dates Parameters |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|