Skip to main content
Solved

Use of a Field in Substring

  • February 25, 2026
  • 3 replies
  • 27 views

dguild
Freshman I

I’m trying to pull one character out of the PMProject.ContractCD field in Report Designer.  Using this expression...

=Substring(CStr([PMProject.ContractCD]), 5, 1)

...a “0” is always shown no matter what number is in the numeric 8 position field.  This expression DOES work in a GI, however, and pulls the correct digit.  How can I get this to work in Report Designer?   

Best answer by DipakNilkanth

Hi ​@dguild

As per your formula, I tested it in both the Generic Inquiry (GI) and the Report Designer.

In the Report Designer, it shows the sixth character. However, in the GI, it displays the fifth character.

It appears that GI calculates the position starting from 0 (zero-based indexing), while the Report Designer counts from 1 (one-based indexing), which explains the difference in the output.

 


 

 

3 replies

darylbowman
Captain II
Forum|alt.badge.img+16

...no matter what number is in the numeric 8 position field.

What does this mean?

The ‘start’ indicator should be zero-based, which means your formula should return the sixth character counting from the left.


DipakNilkanth
Pro III
Forum|alt.badge.img+14
  • Pro III
  • Answer
  • February 25, 2026

Hi ​@dguild

As per your formula, I tested it in both the Generic Inquiry (GI) and the Report Designer.

In the Report Designer, it shows the sixth character. However, in the GI, it displays the fifth character.

It appears that GI calculates the position starting from 0 (zero-based indexing), while the Report Designer counts from 1 (one-based indexing), which explains the difference in the output.

 


 

 


dguild
Freshman I
  • Author
  • Freshman I
  • February 25, 2026

...no matter what number is in the numeric 8 position field.

What does this mean?

This only means that in [PMProject.ContractCD] there are only 8digit numbers. 

I wanted to pull only the 5th number which in the GI is Substring(x,5,1).  Just like Excels’ MID.  But turns out that in Report Designer, that pulls the 6th digit.  I changed to: 

=Substring(CStr([PMProject.ContractCD]), 4, 1) … and now am getting the expected result.

Thanks for your response!