1

I have Ingres DB and a table with timestamp column (seconds since 01/01/1970). I need to find all entries which happened today. Possible solution is:

SELECT * FROM table WHERE date(_date(timestamp)) = date('today')

However, converting every timestamp into ingresdate is not the most efficient and I would like to just compare integers (i.e. timestamp > x() AND timestamp < x() + 86400)

Is there a way to convert date('today') into timestamp? I cannot find anything about it in ingress documentation.

Jaroslaw Pawlak
  • 5,538
  • 7
  • 30
  • 57

1 Answers1

-1

For conversion purpose, have you tried

 TIMESTAMP(CURRENT_DATE)

or

TIMESTAMP(DATE '2015-04-08')

or perhaps use the DATE_TRUNC() function?

plomien
  • 77
  • 2
  • 11
  • `TIMESTAMP(CURRENT_DATE)`, `timestamp(date('today'))` and `date('today')` return exactly the same value: `2015-04-09 00:00:00.0` – Jaroslaw Pawlak Apr 09 '15 at 13:32
  • sorry i'm a bit confused, you wanted to convert date to timestamp right? so how about: `SELECT * FROM table WHERE your_timestamp_column = TIMESTAMP(CURRENT_DATE)`? – plomien Apr 09 '15 at 13:53
  • Have you read my question? My timestamp column has nothing to do with `ingresdate`: `Function '=' is not defined for arguments of type 'integer' and 'ingresdate'. Explicitly convert its arguments to the desired type(s).` – Jaroslaw Pawlak Apr 09 '15 at 13:55
  • Sorry, i skiped that part about seconds. Well, have you tried `SELECT EXTRACT(EPOCH FROM date('today'))` ? – plomien Apr 09 '15 at 14:13