Finn is missing
Finn is missing

Reputation: 47

How to convert date to milliseconds in runtime?

I want to convert date to milliseconds and query the result.

SELECT count(*) FROM TableA WHERE DATE = '2017/09/24';

So I want to replace date '2017/09/24' to the milliseconds value and fetch data.

Upvotes: 0

Views: 2356

Answers (2)

Finn is missing
Finn is missing

Reputation: 47

SELECT count(*) From TableA WHERE Date BETWEEN unix_timestamp('2017-03-10 00:00:00') AND unix_timestamp('2017-03-10 00:00:00'); 

This worked in MySQl for me.

Upvotes: 1

GrabNewTech
GrabNewTech

Reputation: 641

Try this

SELECT
  COUNT(*)
FROM TableA
WHERE TO_CHAR(DATE, 'YYYY/MM/DD HH:MI:SSSSS') = '2017/09/24 10:10:86399';

Play with different date formats. Here is link

PS: Sorry I replied for oracle DB.

Upvotes: 0

Related Questions