November 22nd, 2014, 05:09 AM
Query between two dates
Been trying to query a table date column from a form text input to show all rows between two dates using the BETWEEN operator but its not showing the end date. Whatever I try with the syntax shows all but the end date.
Is there any way to add something like +24 hrs to the end date or to the variable? I have also tried <= >= and nothing seems to work. Seems the between operator is not all inclusive.
November 22nd, 2014, 07:22 AM
If you could provide your current/attempted scripting, we would be able to help a bit more.
IF I am correct, BETWEEN is ran rather literally. Say if you ask BETWEEN 5 and 10, it would result with only 4 items. 6,7,8, and 9. If your current script is running as desired other than that very last date, simply add 1 day to the variable before running the query, as a simple/quick fix.
Last edited by Triple_Nothing; November 23rd, 2014 at 06:57 AM.
He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
November 22nd, 2014, 07:35 AM
Yes that would fix it, but I don't know the syntax to add 1 day to the variable. Thanks
November 22nd, 2014, 08:49 AM
$date = '2014-11-22';
$date = date('Y-m-d', strtotime("$date + 1 day"));
November 22nd, 2014, 04:30 PM
Thanks dude but not really what I was looking for. I have resolved it though by reassigning the variable similar to what was suggested earlier, I just added ++ in front. This actually added + 1 day to the value!
November 22nd, 2014, 07:00 PM
November 22nd, 2014, 10:42 PM
Don't call me "dude". That's how a child addresses another child. I'm an adult.
The solution I provided answered your "Is there any way to add something like +24 hrs to the end date or to the variable?" question given that you didn't provide any of your code so I had to guess your code.
How do I ask a good question? - Help Center - Stack Overflow
November 23rd, 2014, 03:31 AM