Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date convertion 1

Status
Not open for further replies.

patrick118

Technical User
Jan 14, 2004
315
NL
This probably is an easy question for some of you but for me it's difficult. Here is my problem.

In a crystal report i have a field with number like this
19970328 This is a day of birth for someone. Now my problem is i would like the format to be like this
28031997 How do i this with a crystal formula?

suppose the field is {gb_date}

Hope someone can help

Thank you for helping me
 
Assuming this is a number field then you can do:

stringvar x;
x:=cstr({mytable.gb_date});
right((x,2)& mid(x,3,2) & left(x,4)

(This returns a textfield)
 
Almost there. I had the following in the formula

stringVar x;
x:=cstr({JEUGD.D_GEBOORTE});
Right(x,2)& Mid(x,3,2) & Left(x,4)


the numbers in the field were 19690919 the outcome after the formula was 19691969. This isn't correct it should be 19091969

Hope you can see what's wrong. I can't

Thanks Patrick
 
You can use this to convert it to a date:

cdate(val(cstr({JEUGD.D_GEBOORTE},"#")[1 to 4]),val(cstr({JEUGD.D_GEBOORTE},"#")[5 to 6]),val(cstr({JEUGD.D_GEBOORTE},"#")[7 to 8]))

Place the formula on the report, then right click it, choose format field, and format the date to whatever format you like.



~Brian
 
You could also do this in the formula as an alternative:

cdate(int({JEUGD.D_GEBOORTE}/10000),int(remainder({JEUGD.D_GEBOORTE},10000)/100),remainder(remainder({JEUGD.D_GEBOORTE},10000),100))

~Brian
 
It is working like a charm. Thank you very much lupins.

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top