# Date being returned as "1,672,437,600,000" when binding named query to table in Perspective

**URL:** <https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682>\
**Category:** Ignition\
**Tags:** ignition81, database, perspective\
**Created:** [December 15, 2022, 5:11pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682 "2022-12-15T17:11:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 5:11pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/1 "2022-12-15T17:11:35Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db54d7deda5022cc70fbe3a13f90426640cf3f75.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78a478ccb7fc029d42f3874323ead4bef3bb8f78.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e42b2e86c6bdf6e158806011e14679aec5895c73.png)

When I bind this named query to the data property of my table in perspective the date comes back as a very large number instead of something readable, in my database its a data type "date" and displays correctly.. any ideas?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 15, 2022, 5:13pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/2 "2022-12-15T17:13:17Z")

</div>

That's an epoch milliseconds value. Do you have an entry in the `columns` array for your Date table, and what is it set to treat your column as?

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 5:16pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/3 "2022-12-15T17:16:34Z")

</div>

Within SQL or Ignition? Sorry I don't understand the question.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 15, 2022, 5:26pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/4 "2022-12-15T17:26:49Z")

</div>

In your perspective table component, find the `columns` property under `props`. Add entries to it for each column in your dataset (as needed). The first element in each column object should be a key `field` with a value that exactly matches the column name of your dataset.

Then, further down in the column object corresponding to your `DATE` field, change the 'render' property to 'date', and see if that fixes your issue.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 15, 2022, 5:28pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/5 "2022-12-15T17:28:01Z")

</div>

Like this  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6b5e1ea4d2f10bf91b10a21df421569944bd8c8.png)

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 5:30pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/6 "2022-12-15T17:30:34Z")

</div>

Thank you!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e4e3d0f592cdfd1bed066c43d50b51569a2503e8.png)

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 5:43pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/7 "2022-12-15T17:43:06Z")

</div>

So while I've got you're attention...

I am trying to filter only on the date selected by this date input:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/c/4c479f715f3fca4e62e64ebffcee777eec4ca465.png)

this works for saving when I run my save named query but it does not seem to work when using that same value to filter:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da49e30646c35b48ed6213d9f37e63fb4eac9da7.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 15, 2022, 5:47pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/8 "2022-12-15T17:47:46Z")

</div>

"Does not work" as in returns no data? Or is there any kind of error?

If the former: Is the tag of the correct type? Does it work if you pass the parameter wrapped in the `toDate` expression function (as in, `toDate({path/to/tag})`)

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 5:54pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/9 "2022-12-15T17:54:20Z")

</div>

Sorry, does not work as in returns no data:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b6f0769fd6a37f22aef9357798cd256c1fafb24c.png)

I use the same date input (tag value) to provide the value for the save, and it works.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2aacb37187c97cdfc6362afe0a60f4c82a0648f2.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/13655ac85cebae009f83db10893ef4c4783be7c6.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 15, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/10 "2022-12-15T18:02:29Z")

</div>

Try changing your query where clause to this so it matches on just the date and not the date and time.

```auto
date(DATE) = date(:myPB1AccidentDate)

```

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/11 "2022-12-15T18:06:25Z")

</div>

com.microsoft.sqlserver.jdbc.SQLServerException: 'date' is not a recognized built-in function name.

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 15, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/12 "2022-12-15T18:08:58Z")

</div>

MSSQL is why, you'll have to use the correct date function, which I think is `DATEPART()`. I don't know the correct syntax for using it.

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [December 15, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/13 "2022-12-15T18:18:38Z")

</div>

IIRC your WHERE clause should be something like so:  
`WHERE CAST([Date] AS date) = CAST(:myPB1AccidentDate AS date)`

Also, wrap DATE in your SELECT with `[]`:  
`SELECT [Date]`

actually you might not need to wrap it with `[]`. It worked in SSMS for me without wrapping it

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 6:27pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/14 "2022-12-15T18:27:28Z")

</div>

I tried it both ways, wrapping [DATE] in the select and not, still not returning any data...

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/63c10eb43c0ae93c909754ce55564e30e08f8259.png)

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [December 15, 2022, 6:28pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/15 "2022-12-15T18:28:02Z")

</div>

is it giving you any errors?

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 6:29pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/16 "2022-12-15T18:29:32Z")

</div>

I have one error in the property editor but it has been there for a while, even when the select \* was working showing the correct date format in the table. I'm unsure how to see what that error is though..

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8eb2e92c0789cc5c719280f2627655f1c30ea82e.png)

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [December 15, 2022, 6:31pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/17 "2022-12-15T18:31:35Z")

</div>

it looks like the query is succeeding, just not returning any data for the selected date.

do you have data in the database table that have a date matching what you're passing into `:myPB1AccidentDate`?

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 6:32pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/18 "2022-12-15T18:32:28Z")

</div>

🥸 i may or may not have had a date selected with no entries...

---

<div class="post-metadata">

**Author:** ![Christopher\_Jacobs](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Christopher\_Jacobs](https://forum.inductiveautomation.com/u/Christopher_Jacobs)\
**Post date:** [December 15, 2022, 6:33pm UTC](https://forum.inductiveautomation.com/t/date-being-returned-as-1-672-437-600-000-when-binding-named-query-to-table-in-perspective/67682/19 "2022-12-15T18:33:40Z")

</div>

it is working...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db1874ab61cb3d5234202e1bc4e27d60e8ba323b.png)

Thank you so much for your prompt help!
