How to format output connector?

Hi,

I’d like to format a string (that come from a connector) that looks like string"/Date(1675690009000+0000)/" in this format string"/Date(1675690009000)/" (remove “+0000”).
In fact it should be a date format but the +0000 suffix prevents Tulip to consider it as a date.
To be more precise i dont want to do this treatment in Tulip App but in the connector output (dot notation ?).

Or maybe there is a other way to make Tulip recognize a date ?

Thank you for your tips/help !

1 Like

Hi @pierre.ponnelle-danj,

you can add some pieces of regexp to yout output like so:

This expression does not fit your needs, but maybe you can try something with this hint…

2 Likes

Hey all,

Thorsten’s idea is likely a great one! alternatively, you can also use the TEXTTODATETIME() function in the Expression Editor to convert your date string to a DateTime - documentation here: Technical Details of the Expression Editor

1 Like

Hi @k.ober,

thats true, but the question was explicitly to avoid this method:

Thats why I came up with regexp in the output. However, it is not so easy to achieve this result with regexp (at least for me).

Ah, you’re right - in this case, I agree with you - Regex and any necessary JSON-Query are absolutely the way to format a connector output. Unfortunately, I think I also agree with you that it’s pretty hard to get this to come out of the Connector looking exactly as we want. It might be unfortunately necessary to use the Trigger logic, as I don’t think there are any ways to cast output variables formally in Connectors at the moment. On the bright side, using Expressions is relatively low-overhead; I recommend the very first time you wish to interact with this object, doing it in an Expression to avoid unnecessary middle-of-process variables.

Thank you for your replies !
I have the begining with this expression : /Date[()]\w+
image

Do you know any existing way to “concatenate” this string with “)/” at the end ?

Pierre

Unless there’s ways to add strings in JSON-query - I don’t think it’s doable with regex. However - you could likely snip the /( from the start with lookback/look-ahead arguments? in other words, have the regex specifically return only what is inside the parentheses, etc

Found ! After hours spent…
But just needed to format this : “/Date(1675689790000+0000)/” into this “1675689790000”
And Tulip correctly recognizes it as a date format.

Expression : :regexp(\w{13})

Thx

3 Likes

Thanks for the feedback