cancel
Showing results for 
Search instead for 
Did you mean: 

Storing values

former_member1107312
Participant
0 Kudos

I have a sub-report that I am using to filter out serial number. When the report comes back and showing multi values here I want to store that previous value, in this case it would be the date value I am interested in.

For Example:

Quality Date Serial Number

123 01/01/2017 10:10:00PM 12345

80 20/01/2017 08:00:00AM 12345

0 31/01/2017 06:50:23PM 12345

I want to store the date in the second line (one previous from the 0 quality). Also I want only to store the date ( I am using this function: totext({fielddate.table}, "MM/dd/yyyy") I know how to store this value to be a Share StringVar in my Formula workshop. I just don't know how to store this value date as 20/01/2017.

Accepted Solutions (0)

Answers (2)

Answers (2)

abhilash_kumar
Active Contributor
0 Kudos

Hi Gerald,

Assuming these are 'separate' columns, you'd need to do something like this:

1. Create a formula with this code and place it on the same section as the other columns:

shared stringvar dd;
if {Quality} = 0 then
dd := totext(previous({Date field}), "dd/MM/yyyy");

2. Create another formula with this code to display that previous date - I hope you wish to use this in the Main report:

shared stringvar dd;

Make sure this formula on the Main Report is in a section 'below' the section that holds the Subreport.

-Abhilash

former_member292966
Active Contributor
0 Kudos

Hi Gerald,

If you've already been able to get the correct record then to extract the Date portion, use the Split function to convert the string to an array. Have the space as the delimiter and as long as the date is always going to be the second element it should work.

StringVar x := "80 20/01/2017 08:00:00AM 12345"; 
Split (x, " ")[2]; 

So I put your string into a variable called x. Using x as the input string and " " as the delimiter, I used Split to return the second element in the array which is the date. If you want, you can use the CDate to convert it to a date type. Something like:

StringVar x := "80 20/01/2017 08:00:00AM 12345"; 
If isDate (Split (x, " ")[2]) Then 
   CDate ((Split (x, " ")[2}]) 
Else Date (0, 0, 0); 

So it checks to see if the element is a date or not. If it is then it converts the string to a date. If it's not a date then it returns a NULL date.

Hope this helps,

Brian