IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#45028 - 09/27/13 12:29 PM Adding days to a date
Arch1 Offline
OL Expert

Registered: 02/15/11
Posts: 216
Loc: michigan
Hello, I am producing form letters that require me to add 5 days to the current date.

I looked online and the functions on OL do not work.

Are there any suggestions on what I can do for this?
_________________________
Dan Lixie
Archway
734-713-2417

Top
#45031 - 09/27/13 01:02 PM Re: Adding days to a date [Re: Arch1]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
Dan,

The "AddDaysToDate" function available on our web site works just fine, maybe you didn't use it correctly.

Here's a link to a previous thread where I post an example that uses the AddDaysToDate:

http://www.objectiflune.com/forum2/ubbth...=true#Post43317

This thread was about the creation of a "GetNextBusinessDay" function that adds 1 to the date, or more if we're on Friday or Saturday. You could use this example as a starting point, and modify it to suit your needs.

Regards,
Raphaël Lalonde Lefebvre

Top
#45034 - 09/27/13 02:15 PM Re: Adding days to a date [Re: Arch1]
Arch1 Offline
OL Expert

Registered: 02/15/11
Posts: 216
Loc: michigan
Hello, I am getting this error when putting my function in:

P0030 : No other function declaration is allowed in the global function definition.

What does that mean?
_________________________
Dan Lixie
Archway
734-713-2417

Top
#45036 - 09/27/13 02:22 PM Re: Adding days to a date [Re: Arch1]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
Can you copy-paste your code, so that we can see it?

Top
#45037 - 09/27/13 02:47 PM Re: Adding days to a date [Re: Arch1]
Arch1 Offline
OL Expert

Registered: 02/15/11
Posts: 216
Loc: michigan
function @GetNextBusinessDay():string
define(&res, string, '')
define(&today, string, '')
define(&today_long, string, '')
define(&days_to_add, integer, 0)

% Today's date in short date format. This function assumes
% your system's short date is in DD/MM/YYYY format.
&today := date(false)

% Today's date in long date format. Make sure it includes
% the name of the day.
&today_long := date(true)

% Number of days to add to get the next business day. If we're on
% Friday, we need to add 3. If we're on Saturday, we need to add 2.
% For all other days, we simply add 1.
if(pos('Friday', &today_long) > 0)
&days_to_add := 3
elseif(pos('Saturday', &today_long) > 0)
&days_to_add := 2
else
&days_to_add := 1
endif()

% Use "@AddDaysToDate" to add days to today's date.
&res := @AddDaysToDate(&today, 'DD/MM/YYYY', &days_to_add)

% Return the result.
&Result := &res
endfunction()
_________________________
Dan Lixie
Archway
734-713-2417

Top
#45038 - 09/27/13 02:49 PM Re: Adding days to a date [Re: Arch1]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
Well, this is the exact same code as the thread I've linked.

Did you follow ALL the steps in order to make it work? Because before you can use it, you have to import @AddDaysToDate, and it's required functions. Make sure you read my entire post, and follow the steps.

Top
#45039 - 09/27/13 03:25 PM Re: Adding days to a date [Re: Arch1]
Arch1 Offline
OL Expert

Registered: 02/15/11
Posts: 216
Loc: michigan
It is an old post, must not agree with the newer versions of the software. I have to give up.
_________________________
Dan Lixie
Archway
734-713-2417

Top
#45040 - 09/27/13 03:41 PM Re: Adding days to a date [Re: Arch1]
Arch1 Offline
OL Expert

Registered: 02/15/11
Posts: 216
Loc: michigan

Got it to work.
_________________________
Dan Lixie
Archway
734-713-2417

Top