# Simple Casting or Date Formatting Question

**URL:** <https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165>\
**Category:** Ignition\
**Created:** [August 28, 2020, 2:29pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165 "2020-08-28T14:29:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_S](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bill_s/32/6705_2.png) [@Bill\_S](https://forum.inductiveautomation.com/u/Bill_S)\
**Post date:** [August 28, 2020, 2:29pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165/1 "2020-08-28T14:29:35Z")

</div>

I have an SQL query that returns values averaged by day. I want to plot them on a chart to show the trend.

My values come from a transaction group, so they are saved with a time stamp that I CAST as Date.

When the values are summarized by day, the x-axis date I get back is like Aug 27, 2020 12:00 AM.

My chart ends up with hours of the day on it, but I want just the day.

I can get the format looking right by using CONVERT, but then the chart chokes on it because it wants a time instead of a string.

Is there something I can do to just get the date returned when I cast as date, or should I convert to string and then change my chart to treat the dates like categories? Or is there something else I’m missing here?

Thank you.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 28, 2020, 4:06pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165/2 "2020-08-28T16:06:25Z")

</div>

I typically return the day as a number in the query and then use that.  
Just simplifies things.

---

<div class="post-metadata">

**Author:** ![Bill\_S](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bill_s/32/6705_2.png) [@Bill\_S](https://forum.inductiveautomation.com/u/Bill_S)\
**Post date:** [August 28, 2020, 4:32pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165/3 "2020-08-28T16:32:35Z")

</div>

I’m not sure I understand what you mean. As a number in date format or as an integer?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 28, 2020, 4:58pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165/4 "2020-08-28T16:58:15Z")

</div>

Sorry yes as an integer.  
MS SQL  
`SELECT DATEPART("d",MyDateField) as DayNum`  
Then use DayNum as the axis value.

---

<div class="post-metadata">

**Author:** ![Bill\_S](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bill_s/32/6705_2.png) [@Bill\_S](https://forum.inductiveautomation.com/u/Bill_S)\
**Post date:** [August 28, 2020, 5:10pm UTC](https://forum.inductiveautomation.com/t/simple-casting-or-date-formatting-question/38165/5 "2020-08-28T17:10:58Z")

</div>

That makes perfect sense.

Thank you!
