# Query tag with date/time presentation

**URL:** <https://forum.inductiveautomation.com/t/query-tag-with-date-time-presentation/33317>\
**Category:** Ignition\
**Created:** [March 23, 2020, 2:20pm UTC](https://forum.inductiveautomation.com/t/query-tag-with-date-time-presentation/33317 "2020-03-23T14:20:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarno.vandenberg](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jarno.vandenberg](https://forum.inductiveautomation.com/u/jarno.vandenberg)\
**Post date:** [March 23, 2020, 2:20pm UTC](https://forum.inductiveautomation.com/t/query-tag-with-date-time-presentation/33317/1 "2020-03-23T14:20:56Z")

</div>

Hello All,

I experiance some difficulties with date time presentation in ignition designer.

I have a date in PGSQL, it’s stored as a floatvalue. I have made a query to convert to yyyy-mm-dd-ww and I get the desigred result as an output.

SELECT floatvalue as number  
,cast(floatvalue as integer) / 65536 & 65535 as year  
,cast(floatvalue as integer) / 4096 & 15 as month  
,cast(floatvalue as integer) / 16 & 255 as day  
,cast(floatvalue as integer) / 1 & 15 as w  
FROM public.v\_sqlt\_data\_1\_2020\_03 where tagid=150;

- My tagid value = 132428004
- The machine expected datatype = YYYYYYYYYYYYYYYYMMMMDDDDDDDDWWWW (I know, it’s weird)
- The source is an OPC tag that I log historical (I have some difficulties doing a direct conversion on the tag)

Now when I make a query tag, and I run this query and set the tag datatype as DateTime, I get Jan-02-1970. My result in PGSQL = 2020-11-14-4

When I use the same approach for my service interval countdown timer, my query tag does work fine, however that tag is time (seconds)

Does anybody have any suggestions how I can either do it better, or what I am doing wrong.

Kind regards,  
Jarno van den Berg
