Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

15
  • 18
    What happens if you try to find the difference of two VARCHAR objects? Commented Feb 9, 2021 at 12:21
  • 14
    Or "how many days are there between date1 and date2?" or "what ISO week number is date1?" or "select all records where date1 is a Monday?" etc etc etc Commented Feb 9, 2021 at 12:33
  • 33
    I suggest you benchmark your method against doing the same comparisons natively in the database. Don't be surprised if the database is 100x quicker. Commented Feb 9, 2021 at 12:41
  • 3
    Lets just say you have 100 orders a year for the last 10 years. If you wanted all the orders within the last year, what is more logicial and optimised, get the database to return only the records you need OR loop through all the records yourself and collect the ones that match your criteria. Commented Feb 10, 2021 at 0:24
  • 8
    "In comparing such objects I would just convert them into datetime objects in php and then do the comparing." Why are you using an SQL database if you're not going to use SQL? Commented Feb 10, 2021 at 5:34