# Dateformat from query datetime or string for specific date format

**URL:** <https://forum.inductiveautomation.com/t/dateformat-from-query-datetime-or-string-for-specific-date-format/96112>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 18, 2024, 9:59am UTC](https://forum.inductiveautomation.com/t/dateformat-from-query-datetime-or-string-for-specific-date-format/96112 "2024-09-18T09:59:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [September 18, 2024, 9:59am UTC](https://forum.inductiveautomation.com/t/dateformat-from-query-datetime-or-string-for-specific-date-format/96112/1 "2024-09-18T09:59:40Z")

</div>

Hello!

I got a query than requires a date with specific date format MM/YYYY

```python
SELECT WO.WORKTYPE || ' - ' || WT.WORKTYPENAME AS DESCRIPCION,
       COUNT(WO.WORKORDER) AS PETICIONES
FROM WORKORDER WO
INNER JOIN WORKTYPE WT ON WT.WORKTYPE = WO.WORKTYPE
                      AND WO.COMPANY = WT.COMPANY
WHERE WO.COMPANY = 'GESTIONESP'
  AND TO_CHAR(WO.WORKREQUESTDATE, 'MM/YYYY') = :startDate
  AND WO.BUSINESSUNIT IN (:listSites)
GROUP BY WO.WORKTYPE, WT.WORKTYPENAME
ORDER BY WO.WORKTYPE, WT.WORKTYPENAME

```

but this format is not valid if the DataType is DateTime....

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05ae9634f4ca9eb3e2ff46f0a0c6bc22854b035d.png)

I guess is ok to just use string as DataType in this case

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/593a8a5b5300947662df8ca5b25b1837929e3886.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 18, 2024, 10:11am UTC](https://forum.inductiveautomation.com/t/dateformat-from-query-datetime-or-string-for-specific-date-format/96112/2 "2024-09-18T10:11:44Z")

</div>

The answer is the same as your related question, [Date format for query filter - #4 by Transistor](https://forum.inductiveautomation.com/t/date-format-for-query-filter/96105/4). You should be using datetime objects, not strings.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [September 18, 2024, 10:17am UTC](https://forum.inductiveautomation.com/t/dateformat-from-query-datetime-or-string-for-specific-date-format/96112/3 "2024-09-18T10:17:19Z")

</div>

Thanks Transistor!, ight now I don't have access to modify the database or control the format of the `:startDate`, I just transforming Ignition Vision version to Perspective
