Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Return dates from an array Post Reply Post New Topic
Author Message
barry.ein
Newbie
Newbie
Avatar

Joined: 18 Feb 2015
Location: Israel
Online Status: Offline
Posts: 12
Quote barry.ein Replybullet Topic: Return dates from an array
    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
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.