• Status: Solved
• Priority: Medium
• Security: Public
• Views: 265

# Convert String to Date

How do I convert the following String to Date with a formula
String "050708"
Where 05 is the day, 07 is the month and 08 is the month
So I would get the output like
05-July-08
0
ranhell
• 2
1 Solution

Author Commented:
Correction
How do I convert the following String to Date with a formula
String "050708"
Where 05 is the day, 07 is the month and 08 is the year
So I would get the output like
05-July-08
0

Author Commented:
I figure it out by myself

Local NumberVar ano;
Local NumberVar mes;
Local NumberVar dia;
if Length ({TEMPIN.CB}) = 30 then
(   dia := tonumber(left(right({TEMPIN.CB},27),2)) ;
mes := tonumber (left(right({TEMPIN.CB},24),1));
ano := tonumber (left(right({TEMPIN.CB},23),2))+ 2000;
datevalue(ano,mes,dia);
)

Else
(   dia := tonumber(left(right({TEMPIN.CB},15),2)) ;
mes := tonumber (left(right({TEMPIN.CB},12),1));
ano := tonumber (left(right({TEMPIN.CB},11),2))+ 2000;
datevalue(ano,mes,dia);
)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.