HTMHell
HTMHell

Reputation: 6006

Check if timestamp is today using SQL

I've seen some questions that asked about it, but nothing helped me.

I have a column named timestamp, and inside it there is a timestamp value, that says when it inserted. for example: 1366030060.

I want to select only the rows that inserted today. I'm using Mysql

This is my code: (I added the WHERE and it's not working)

        SELECT      `chat`.`message`,
                    `chat`.`timestamp`,
                    `users`.`username`,
                    `users`.`id`
        FROM        `chat`
        JOIN        `users`
        ON          `chat`.`userid` = `users`.`id`
        WHERE       `chat`.`timestamp` >= UNIX_TIMESTAMP(CURDATE())
        ORDER BY    `chat`.`timestamp`
        DESC

Upvotes: 1

Views: 4289

Answers (1)

Kermit
Kermit

Reputation: 34055

SELECT colList
FROM tbl
WHERE timestampCol >= UNIX_TIMESTAMP(CURDATE())

Upvotes: 8

Related Questions