Get records between date for example in mysql
2009-08-11 to current date
2009-08-11 is to retrieve all date , this is just an example
I have tried WHERE time between date(time) and DATE(time) = CURDATE();
Get records between date for example in mysql
2009-08-11 to current date
2009-08-11 is to retrieve all date , this is just an example
I have tried WHERE time between date(time) and DATE(time) = CURDATE();
A lot of it depends on the data type for the field you are storing the date ( DATE, TIME, DATETIME, TIMESTAMP, or YEAR) in. You need to make the data you are searching against look like the data type.
Try this:
where table.date_field >= starting_date and <= CURDATE();
Or this if the field is a timestamp data type:
where table.datetime_field >= starting_datetime and <= NOW();
And use your fields holding the datring_date and the field in the table to check agianst. Make sure that the data type is
Why couldn't we use between keyword?
Like, where (table.date_field Between starting_date and CURDATE();
If you want to take out the time component, use date function.
E.g. where date(tbl.datefield) >= date(:dateparam)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.