Page 1 of 1

Format Date when it is Private Data

Posted: Fri Feb 10, 2023 7:24 pm
by bpletka
Is there a way to format a date when it is Private Data?

Data is current showing 01-Jan-23. The formatting needs to show 1/1/2023.

Thanks-

Bill

Re: Format Date when it is Private Data

Posted: Fri Feb 10, 2023 7:47 pm
by jan_suhr
Have you tried this for the current date?

CurrentDate=[Switch.Date:Format="d/MMM/yyyy",TimeZone="UTC"]

It will show 10/feb/2023

https://www.enfocus.com/manuals/UserGui ... tting.html

Re: Format Date when it is Private Data

Posted: Fri Feb 10, 2023 8:36 pm
by bpletka
Thanks for the info.

I am in need of formatting a date that is private data. I do not need to generate a date from Switch.

Re: Format Date when it is Private Data

Posted: Fri Feb 10, 2023 10:36 pm
by jan_suhr
Where do you get your date from? Can it be formatted from that source?

Re: Format Date when it is Private Data

Posted: Mon Feb 13, 2023 9:33 am
by freddyp
Private data is always a string. Converting it to a Date requires the use of a script (expression).

I tried a second approach using Jan's apps "Make XML/JSON". I hoped that placing the private data into a very simple XMLJSON dataset and extracting it using the Date type would recognize it as a Date, but unfortunately it did not.

Re: Format Date when it is Private Data

Posted: Mon Feb 13, 2023 9:47 am
by jan_suhr
Maybe the app Date Calculator can fix it for you. It is possible to calculate with the value zero for the new date. You will get a lot of private data keys for different parts of the date. It will however give it in ISO-format, it meant to be used in Switch.

But you can use the string replace app to format the date to your needs.

Re: Format Date when it is Private Data

Posted: Tue Feb 14, 2023 7:27 pm
by bpletka
I did try the date calculator app. That will not work as the date must be yyyy-MM-dd or it will fail.

I have the app for string replacement. I am struggling to understand the setup of the app. The instructions are not clear to me.

Re: Format Date when it is Private Data

Posted: Tue Feb 14, 2023 7:54 pm
by jan_suhr
bpletka wrote: Tue Feb 14, 2023 7:27 pm I did try the date calculator app. That will not work as the date must be yyyy-MM-dd or it will fail.

I have the app for string replacement. I am struggling to understand the setup of the app. The instructions are not clear to me.
You haven't really told us what the input is, where it come from and in which format.

With the Date Calculator app you will get a lot of PrivateData tags and from them you can construct the date format you want.
You could also use the app Row2Variables where you can have an Excel table with the month digits and the corresponding text for each numeric value.

It will work in the way that you get 03 from the Date Calculator and in the Row2Variable you call the PrivateData tag with the month number and you will get a new PrivateData with the text "MAR" (or what ever you decide to match 03) With these PrivateData tags you can construct your date to 15/MAR/2023

Re: Format Date when it is Private Data

Posted: Thu Feb 16, 2023 5:01 pm
by bpletka
The data is coming out of tab delimited file and split through the ASI List Magic App. This becomes private data. Switch does not see this as a date in its current form. That is when I realized I could go about this a different way and I figured out a fix.

I used string splitter to create new private data and then used string replace to change the data. I combined it all in the meta tagger to create the date format I needed.

Thanks for all the input and ideas!