0

Trying to capture some information when a user inputs two dates. The information I'm getting back is correct apart from the dates are off by one. So if I ask for 13th 14th 15th I get the correct information back but the dates are 12th 13th 14th.

Found the issue it's to do with BST time being 1 hour ahead. Just not really sure how to rectify it apart from sticking my PC an hour behind.

  • Your timezone might be set incorrectly, see: [https://stackoverflow.com/questions/2934258/how-do-i-get-the-current-time-zone-of-mysql](https://stackoverflow.com/questions/2934258/how-do-i-get-the-current-time-zone-of-mysql), or the data for your system is wrong? – Luuk Apr 04 '21 at 15:44
  • 1
    You didn't share any sample data nor the values you tried nor where you try it. It is a string that you shared with possibly a parameter array. You need to share the language you are trying this with. Please share your actual piece of code, including how you define your parameters. – Cetin Basoz Apr 04 '21 at 15:46
  • What does it have to do with BST or daylight savings? UTC times are universally same, regardless of zone and daylight saving, no? – Cetin Basoz Apr 04 '21 at 16:38
  • Just tested it on my computer. Database is running local host. I'm currently 1h ahead of UTC and if I put it back to UTC it works fine. So it's obviously something to do with the 1h time difference I'm just not sure what. – NewToCoding Apr 04 '21 at 16:53

1 Answers1

0

Check the date stored in the database it might be stored in UTC Format. If it is in UTC Format, you must handle it in your code to match on your time zone.

  • What does it matter to store in UTC (which likely should be preferred)? If the parameter dates are also in UTC I would get back the range I want, no? -apart from that, with date\datetime ranges I wouldn't use BETWEEN but >= and < style upper boundary exclusive query. – Cetin Basoz Apr 04 '21 at 15:49