# Help writing a statement please

**URL:** <https://community.asterisk.org/t/help-writing-a-statement-please/9691>\
**Category:** Asterisk Support\
**Created:** [October 4, 2006, 6:04pm UTC](https://community.asterisk.org/t/help-writing-a-statement-please/9691 "2006-10-04T18:04:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiRAD](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@DiRAD](https://community.asterisk.org/u/DiRAD)\
**Post date:** [October 4, 2006, 6:04pm UTC](https://community.asterisk.org/t/help-writing-a-statement-please/9691/1 "2006-10-04T18:04:43Z")

</div>

HI all,  
Can you please help me write me a statement, i know how to do it in SQL, but i don’t know how to do it in mysql through asterisk.

this is the statement

Select field1 from tablename where ({ fn NOW()} \> datetime\_variable + ‘10:00:00 am’)

thanks in advance.

---

<div class="post-metadata">

**Author:** ![DiRAD](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@DiRAD](https://community.asterisk.org/u/DiRAD)\
**Post date:** [October 5, 2006, 5:23pm UTC](https://community.asterisk.org/t/help-writing-a-statement-please/9691/2 "2006-10-05T17:23:08Z")

</div>

Just got it to work

exten =\> s,3,MYSQL(Query resultid ${connid}\ SELECT\ field1\ from\ TableName\ where\ DATE\_FORMAT(curdate(),’%Y-%m-%d\ %h:%i:%s %p’ )\>\ DATE\_FORMAT(DATE\_ADD(DateTimeFieldInTheDB,\ INTERVAL\ ‘10:00’\ HOUR\_MINUTE),’%Y-%m-%d\ %h:%i:%s\ %p’)

What this thing saying: Is now \> 10:00 am on the DateTimeFieldinTheDB. if yes, it will bring back the value in field1, if not, it will be null.

if you want to go the difficult way, create a PHP file, pass in the date, do y our caculation there and them pass the result out.

I hope that helps somebody.
