Print Page | Close Window

Return dates from an array

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22930
Printed Date: 03 May 2024 at 9:51am


Topic: Return dates from an array
Posted By: barry.ein
Subject: Return dates from an array
Date Posted: 21 Mar 2021 at 12:12am
Hi all,

I have the following formula that returns all days between two date fields as a string:

local datetimevar aDate :={PR.DATE_OPENED};
local stringvar dateList:="";
local numbervar xx:={PR.DATE_CLOSED}-{PR.DATE_OPENED};
local numbervar i:=0;
for i:=1 to xx+1 do
(
    dateList:=dateList+left(totext(aDate),10); //,"mm/dd/yyyy");
    local datetimevar aDate:=dateadd("d",1,aDate);
);
dateList;

I would like to see the returning values as date values and not strings so I can run additional searches on them.

Thank you,

Barry



Replies:
Posted By: lockwelle
Date Posted: 26 Mar 2021 at 12:00pm
you could create an array of dates. I am rusty and I would double check my syntax.

local stringvar dateList:="";
local numbervar xx:={PR.DATE_CLOSED}-{PR.DATE_OPENED};
shared datetimevar array result(xx);  //I think this initializes the array for xx elements
local numbervar i:=0;
for i:=1 to xx+1 do
(
    dateList:=dateList+left(totext(aDate),10); //,"mm/dd/yyyy");
    result := aDate;    //assign the date to the array
    local datetimevar aDate:=dateadd("d",1,aDate);
);
dateList;
//don't need to return the date array as it is shared and can be accessed from anywhere in the report.


HTH



Print Page | Close Window