# Configuring a DateTime SQLTag in TagProvider

**URL:** <https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994>\
**Category:** Module Development\
**Created:** [February 13, 2012, 9:23pm UTC](https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994 "2012-02-13T21:23:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![denji26](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/denji26/32/5805_2.png) [@denji26](https://forum.inductiveautomation.com/u/denji26)\
**Post date:** [February 13, 2012, 9:23pm UTC](https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994/1 "2012-02-13T21:23:45Z")

</div>

In my SQLTagProvider I am configuring a tag of type DateTime. When I view my tag in the designer, instead of seeing the date value, I see #,##0.## which is the Format String that has been set for that tag. When I edit the tag and set the format string to yyyy-MM-dd h:mm:ss aa then my datetime appears properly for my tag.

When configuring the tag in my TagProvider, how can I set that format string so that my DateTime values appear properly?

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [February 14, 2012, 9:49pm UTC](https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994/2 "2012-02-14T21:49:49Z")

</div>

Strangely, it appears that that may not currently be possible. I think there should probably be an overload of configureTag and/or configureTagType that takes a set of default tag properties for the tag. In that case, you could just include the desired format string.

However, we probably should also default to a format string appropriate for the type of the tag…

I’ll try to get these in to 7.3 soon.

Regards,

---

<div class="post-metadata">

**Author:** ![denji26](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/denji26/32/5805_2.png) [@denji26](https://forum.inductiveautomation.com/u/denji26)\
**Post date:** [March 1, 2012, 11:05pm UTC](https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994/3 "2012-03-01T23:05:51Z")

</div>

We found a way to make it work using a TagDiff:

TagDiff tagDiff = new TagDiff();  
tagDiff.setAttribute(TagProp.FormatString, new BasicTagValue(“yyyy-MM-dd hh:mm:ss a”));

TagPath tagPath;

tagPath = TagPathParser.parse(“Tag/Timestamp”);  
context.getTagManager().editTags(Arrays.asList(tagPath), tagDiff);

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 1, 2012, 11:10pm UTC](https://forum.inductiveautomation.com/t/configuring-a-datetime-sqltag-in-tagprovider/3994/4 "2012-03-01T23:10:55Z")

</div>

Ah, you’re absolutely right… by doing that, you’re creating an “extension” for the tag, which will get applied on load. Don’t know why I didn’t think about that… it’s basically the same as going in the designer, editing the tag, and changing the format.

Anyhow, I will put the new version of configureTag in for 7.4, to make everything easier.

Regards,
