cancel
Showing results for 
Search instead for 
Did you mean: 

Beginner question...

tallshipsgo
Discoverer
0 Kudos

Hello All. I've been given CR to learn and would like to know the purpose of some things in the following string:

cdate(Mid ( Totext ({sample.datefield},0,''),5,2) + '/' + Right( Totext ({sample.datefield},0,''),2) + '/' + Left ( Totext ({sample.datefield},0,''),4))

This formula produces the following string in output: 05/02/2023. What is the purpose of the {samle.date} Mid Right and Left? What does the ,0, or ,5,2 do?

Thank you all for your time.

tallshipsgo
Discoverer
0 Kudos

Figured it out.

jerryjanda
Community Manager
Community Manager
0 Kudos

Hi, Nicholas:

Could you please provide the solution that you figured out, publishing as an answer? It could be useful to other members who experience similar issues. Otherwise, we'll need to delete the thread, as a closed question with no real answer doesn't serve much purpose in the community.

Kind regards,

--Jerry

Accepted Solutions (0)

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Kudos

You could find most of this information in the Crystal Help, which is actually quite good.

{sample.datefield} supposedly is a date field, but from the formula I suspect that it's actually a number in the format yyyymmdd.

ToText({sample.datefield}, 0, "") converts the number to a string with no decimal places (specified by the 0) and no commas (specified by the "").

Mid(<string>, 5, 2) gets a substring starting at the 5th character, returning 2 characters. So the "mm" part of the yyyymmdd string.

Right(<string>, 2) gets the two characters at the end of the string.

Left(<string>, 4) gets the four characters at the beginning of the string.

-Dell