Page 1 of 1

converting to date for comparing dates

Posted: Sat Dec 09, 2017 2:13 am
by Analytics123
hi , i have in my source file values like for date

6/10/2015
Is there a specific code to append 0 before 6 or a code to say if the length of month or day is 1 then append 0 in front of it .

Thanks,

Re: converting to date for comparing dates

Posted: Sat Dec 09, 2017 2:32 am
by Wim Gielis
Did you spend a minute in the help on TM1 rules functions ? Long, Scan, Insrt, and so on.

Re: converting to date for comparing dates

Posted: Sat Dec 09, 2017 2:54 am
by Analytics123
i know scan will help to get the '/ 'position, but is there a way to get the first and second slash position too.

Yes i know we can come up with logic, but you dont think its too much calculation , if length is 10 then the date otherwise , check if length is 8 or length is 9 .

Re: converting to date for comparing dates

Posted: Sat Dec 09, 2017 3:46 am
by Alan Kirk
Analytics123 wrote: Sat Dec 09, 2017 2:54 am i know scan will help to get the '/ 'position, but is there a way to get the first and second slash position too.

Yes i know we can come up with logic, but you dont think its too much calculation , if length is 10 then the date otherwise , check if length is 8 or length is 9 .
I do. Which is why I think you should approach whoever is supplying you with this data and tell them to get their head out of their backside and start supplying it in a consistent format. It's really not a particularly arduous thing to do out of any half-decent database, or even Excel come to that.

In the meantime, in the absence of a Split function in TI (one of many annoying absences) the only thing that you can do is use the string functions that Wim mentioned to work out the split. There's no standard function to do it for you.

Bear in mind though that if your data suppliers have been kind enough to be consistent about using a 4 digit year, you can use SubSt split off the last 5 characters. That way you need find only one slash, and split that string to get day and month.