Selecting UNIX time within the SQL statment?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Selecting UNIX time within the SQL statment?

Post by alexus »

Hi
i know im close to what i want but cant get it right :-(

here is what i have, user logs in and time() unix timestam is recirded, now i wan to find out who loged in within last 30 sec so i do:

SELECT * FROM users WHERE timestamp >= ROM_UNIXTIME(0)-30;

But that doesnt work... :-( can some one corect me? thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

UNIX_TIMESTAMP(NOW()) - 30
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

ok thanks!
will try that
I was so furstrated so I did a buffer

Code: Select all

$timestamp=time()-30
SLECT ... WHERE timestamp >= '$timestamp';
Post Reply