Kural Manivannan
Kural Manivannan

Reputation: 55

How to format a string to date in tibco spotfire

I am unable to parse a string which looks like "04/20/2016" to date format in Tibco spotfire. Strings of format "04-20-2016" is been parsed to date when I use parseDate("04-20-2016","MM-dd-yyyy"), but the same function doesn't work for "04/20/2016" the result is just empty.

I can simply use Date("04/20/2016") which successfully parses the string to 20-Apr-2016, but when I open the same in web Player its again empty, It works only when I open the .dxp file in my local machine.

Upvotes: 0

Views: 14750

Answers (2)

Tebow
Tebow

Reputation: 1

To make it work for dates without leading 0, you can implement:

ParseDate(Substitute([StringDate],"/","-"),"d-M-yyyy")

Upvotes: 0

niko
niko

Reputation: 3974

I can reproduce your issue in the thick client. as a workaround, you can use Substitute() to replace / with -:

ParseDate(Substitute([d],'/','-'), "mm-dd-yyyy")

it's also worth noting that if your date format is mm-dd-yyyy and your date is 4/20/2016, ParseDate() won't be able to parse it (it's expecting a leading 0 for the mm).


I don't have access to a Web Player instance to check the Date() function, but I would suggest to check the regional settings on the Web Player machine and make sure it's the same format as the incoming date (i.e., if the format is dd/mm/yyyy on the host machine, it will try to parse 04/20/2016 and fail as there's no 20th month).

Upvotes: 1

Related Questions