Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating function for future dates

Status
Not open for further replies.

Dross

Programmer
Aug 16, 2001
212
US
I have a function for a parameter for the users to select dates in the past and they rely on the canned functions already in crystal. For instance:
If psRunPeriodParameter = "Yesterday" Then
CurrentDate - 1
Else

If psRunPeriodParameter = "Week To Date" Then
Minimum(WeekToDateFromSun)
Else

If psRunPeriodParameter = "Last Full Week" Then
Minimum(LastFullWeek)
Else

If psRunPeriodParameter = "Month To Date" Then
Minimum(MonthToDate)
Else

If psRunPeriodParameter = "Last Full Month" Then
Minimum(LastFullMonth)
Else

If psRunPeriodParameter = "Last 30 Days" Then
Minimum(Aged0To30Days)

I do not see corresponding functions for future dates. Has anyone ever had to create this?
 
Hmmm...no one seems to have a n answer?
 
You can use CurrentDate + any number. What future range did you want to use?
 
I need to make a similar function like above but using future dates (pre defined). Problem is Crystal has past pre-built functions that I am using now but no corresponding future functions.
 
next 30 days would just be Currentdate+1 to Currentdate+31

Next full month is a little trickier, I have functions for Beginning of Month and End of Month to make it easier:

Function (DateVar Tdate)
// BOM - Beginning of Month, returns the first day of the month of the date entered
// INPUT: Tdate - the target date ex: 2/19/2003
// OUTPUT: The first day of that month ex: 2/01/2003
// Example: BOM(2/19/2003) = 2/1/2003
local numbervar YY := Year(Tdate) ;
local numbervar MM := Month(Tdate) ;
local numbervar DD := Day(Tdate) ;
Date (YY,MM ,1 ) ;

Function (DateVar Tdate)
// EOM End of Month returns the last day of the month of the entered date
// INPUT: Tdate the target date
// OUTPUT: Last day of the month
// Example: EOM(2/19/2003) = 2/28/2003)
local numbervar YY := (if Month(Tdate) < 12 then Year(Tdate) ELSE Year(Tdate)+1);
local numbervar MM := (if Month(Tdate) < 12 then Month(Tdate)+1 else 1) ;
Date(YY,MM ,1 ) -1 ;

If you have those, then your range is BOM(dateadd("m",1,Currentdate)) to EOM(dateadd("m",1,Currentdate))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top