# Comparing datetime

**URL:** <https://community.asterisk.org/t/comparing-datetime/9547>\
**Category:** Asterisk Support\
**Created:** [September 28, 2006, 8:02pm UTC](https://community.asterisk.org/t/comparing-datetime/9547 "2006-09-28T20:02:54Z")\
**Posts on this page:** 5\
**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:** [September 28, 2006, 8:02pm UTC](https://community.asterisk.org/t/comparing-datetime/9547/1 "2006-09-28T20:02:54Z")

</div>

Hi all,  
I’m new to Asterisk, and i’m learning it piece by piece, one of things that i’m not able to do is to compare a datetime that i get from a DB with the system time…

if somebody can help with that it would be great.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![baconbuttie](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/baconbuttie/32/916_2.png) [@baconbuttie](https://community.asterisk.org/u/baconbuttie)\
**Post date:** [September 29, 2006, 4:27am UTC](https://community.asterisk.org/t/comparing-datetime/9547/2 "2006-09-29T04:27:15Z")

</div>

if Asterisk can’t do what you want with built-in or custom functions, why not write an AGI script in Perl or PHP ?

---

<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:** [September 29, 2006, 11:07am UTC](https://community.asterisk.org/t/comparing-datetime/9547/3 "2006-09-29T11:07:48Z")

</div>

Hi baconbuttie  
I don’t know if asterisk can do it or not, is there a place where i can see all the available functions so i can try them out?

Thanks.

---

<div class="post-metadata">

**Author:** ![baconbuttie](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/baconbuttie/32/916_2.png) [@baconbuttie](https://community.asterisk.org/u/baconbuttie)\
**Post date:** [September 29, 2006, 1:53pm UTC](https://community.asterisk.org/t/comparing-datetime/9547/4 "2006-09-29T13:53:02Z")

</div>

at the CLI `CLI> show functions`

---

<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:31pm UTC](https://community.asterisk.org/t/comparing-datetime/9547/5 "2006-10-05T17:31:55Z")

</div>

baconbuttie, 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.

Thanks for your help
