2

I am trying to write a select statement that includes a where clause that will only return records from the selected date. My table utilizes the Javascript object version of dates. I've tried things like this without success:

select * from my mydb.events where date = some-date-object;

Any help would be appreciated.

GeneBean
  • 361
  • 4
  • 17

1 Answers1

4

The reason that JavaScript does not allow to compare dates directly, because the are objects.

Can you try "===" operator instead "=". The AlaSQL === operator compares not the object references, but convert objects with .valueOf() function to the simple number value.

select * from my mydb.events where date === some-date-object;
agershun
  • 4,077
  • 38
  • 41
  • Would something like this allow me to select all events that happened in a given calendar day? The values in the date objects would include times throughout the day. – GeneBean Jul 28 '15 at 22:01
  • Maybe I need something similar to the LIKE equivalent of === – GeneBean Jul 28 '15 at 22:03
  • You can use DATE() function which converts date to the string like "YYYY-MM-DD". E.g. SELECT * FROM src WHERE DATE(date1) = DATE(date2) – agershun Jul 29 '15 at 02:43