# Need SQL Query help

**URL:** <https://forum.inductiveautomation.com/t/need-sql-query-help/6857>\
**Category:** Archived Topics\
**Created:** [July 12, 2013, 3:56am UTC](https://forum.inductiveautomation.com/t/need-sql-query-help/6857 "2013-07-12T03:56:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [July 12, 2013, 3:56am UTC](https://forum.inductiveautomation.com/t/need-sql-query-help/6857/1 "2013-07-12T03:56:08Z")

</div>

Try to run a query on an Access database from Ignition. Wanting to select the previous 5 minutes of records from the listed time. This is what I tried, but having no luck.

[quote]  
SELECT logdatetime, head1  
FROM logtable  
WHERE logdatetime \>= DATE\_SUB(#2006-10-27 14:59:02#, INTERVAL 5 minute)[/quote]

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [July 17, 2013, 9:07pm UTC](https://forum.inductiveautomation.com/t/need-sql-query-help/6857/2 "2013-07-17T21:07:05Z")

</div>

```auto
SELECT logdatetime, head1
FROM logtable
WHERE logdatetime >= DateAdd("n", -5, #10/27/2006 2:59:02 PM#)
```
