471,049 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

using NOW() and timestamp in sql

Hi Folk

I need to limit the number of emails send within a half our period. Every
time an email is send, it is recorded in my log table (LOG) using NOW() as
entry. The field-type is a timestamp and the name of the field is NOW

How do I rephrase the SQL below to make it work

---
count(`LOG`.`ID`) FROM `LOG` WHERE NOW > x

---

where x = the current server time - half an hour

What should I put in place of x?

TIA

- Nicolaas
Jul 23 '05 #1
1 2237
windandwaves wrote:
Hi Folk

I need to limit the number of emails send within a half our period. Every
time an email is send, it is recorded in my log table (LOG)
using NOW() as entry. The field-type is a timestamp and the name of
the field is NOW
How do I rephrase the SQL below to make it work

---
count(`LOG`.`ID`) FROM `LOG` WHERE NOW > x

---

where x = the current server time - half an hour

What should I put in place of x?

TIA

- Nicolaas


Here is the answer that I devised:

SELECT COUNT( `LOG`.`ID` )
FROM `LOG`
WHERE UNIX_TIMESTAMP( `LOG`.`NOW` ) > ( UNIX_TIMESTAMP( NOW( ) ) -1800 ) ;
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Roger Twomey | last post: by
reply views Thread by Jean-Michel POURE | last post: by
6 posts views Thread by Brandon | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.