2

I'm doing some testing for my system in selecting data between two dates.

so I tried changing my computer's localdate to like year 2020 and run my system, so I'm expecting my CURRENT_DATE is May 10, 2020. and I wont be getting any rows from my query because all of my data is year 2018

But after I use my query of cur_date() its still selecting those 2018 rows. so I thought maybe my Phpmyadmin has its own cur_date().

I'm doing this test for my system will be use for the next couple of years. so I want to try and test my queries if today is already 2025 or something.

1 Answers1

0

I thought maybe my Phpmyadmin has its own cur_date().

PhpMyAdmin has nothing to do with it. Your local computer also has nothing to do with it.

When you put CURDATE() in a query, that's part of the query. It's just text, like the SELECT part or the FROM part.

That means it's evaluated by the MySQL server. Just like the data of your rows is retrieved from the server, not from PhpMyAdmin or your local computer.

So the date returned will be that of the MySQL server.

so I want to try and test my queries if today is already 2025 or something.

The way to do this is to take out the expression CURDATE(), and replace it with the "fake" date you wish to use instead.

Something like:

SELECT * FROM `TheTable` WHERE `TheDate` > '2025-01-01';
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055