Reputation: 299
How do I select all day from 1 parameter, e.g.: I click on any date for May, e.g.: '2018-05-20'. Then, it will return all day in May (1-31). Can it be done in a MySQL query?
P/S: I'm using this for Jaspersoft iReport 5.6.
My query at the moment requires 2 parameters:
SELECT
*
FROM
sample
WHERE
Date >= (Parameter start date) AND Date <= (Parameter end date)
Upvotes: 0
Views: 80
Reputation: 896
This Query will result in all days form your table with respect to the selected date which you pointed "2018-05-20". That mean all the dates in your table on May 2018. Hope this will address your query
SELECT datecolumnName
FROM sample -- <your tablename>
WHERE YEAR(datecolumnName) = YEAR('2018-05-20') AND
MONTH(datecolumnName) = MONTH('2018-05-20');
You can check further Date time functions from here MySQL Date time functions
Upvotes: 1
Reputation: 1433
Try the following:
SELECT * FROM sample WHERE Month(Date) = Month(Parameter start date) And Year(Date) = Year(Parameter start date);
Upvotes: 0