I currently have a @StartDate and @EndDate parameters that prompt the user to enter dates like so 01/01/07. Here is the code below:
(
@StartDate varchar(10),
@EndDate varchar(10)
)
SELECT
tblA.ID,
tblA.Date
FROM
tblA
WHERE
(CONVERT(DATETIME, CONVERT(VARCHAR(10), tblA.Date, 103)) >= @StartDate AND CONVERT(DATETIME, CONVERT(VARCHAR(10), tblA.Date, 103)) <= @EndDate)
This all works as expected, however I now need to enter the parameters so I can enter just the month and year. Is it possible to enter either January 07 or 01/07 as the @StartDate and say March 07 or 03/07 and this would bring back all data from the 1st January to the end of March?
(
@StartDate varchar(10),
@EndDate varchar(10)
)
SELECT
tblA.ID,
tblA.Date
FROM
tblA
WHERE
(CONVERT(DATETIME, CONVERT(VARCHAR(10), tblA.Date, 103)) >= @StartDate AND CONVERT(DATETIME, CONVERT(VARCHAR(10), tblA.Date, 103)) <= @EndDate)
This all works as expected, however I now need to enter the parameters so I can enter just the month and year. Is it possible to enter either January 07 or 01/07 as the @StartDate and say March 07 or 03/07 and this would bring back all data from the 1st January to the end of March?