× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Birgitta,

The v5r4 reference manual makes no mention of an Add_Months() function.

Was it PTF'd in?

Charles


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of BirgittaHauser
Sent: Thursday, May 17, 2007 10:12 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: AW: Months are weird, was '3 Months Ago?'

Hi,

If you want to guarantee, that adding or substracting a
number of months to the month's end will also result in a
month end and if you are already on release V5R4, you can use
the SQL scalar function Add_Months.

Example:
D MyStartDate S D
D MyEndDate S D
*******************************************************************
/Free
MyStartDate = D'2007-05-31';
Exec SQL Set :MyEndDate = Add_Months(:MyStartDate, -3);
Dsply MyEndDate; //--> '2007-02-28'

Exec SQL Set :MyEndDate = Add_Months(:MyEndDate, 3);
Dsply MyEndDate; //--> '2007-05-31'

MyStartDate = D'2007-04-30';
Exec SQL Set :MyEndDate = Add_Months(:MyStartDate, -3);
Dsply MyEndDate; //--> '2007-01-31'

Exec SQL Set :MyEndDate = Add_Months(:MyEndDate, 3);
Dsply MyEndDate; //--> '2007-04-30'

*InLR = *On;
/End-Free


Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the
stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek
Bok) "What is worse than training your staff and losing them?
Not training them and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von
AGlauser@xxxxxxxxxxxx
Gesendet: Thursday, May 17, 2007 15:59
An: RPG programming on the AS400 / iSeries
Betreff: Re: Months are weird, was '3 Months Ago?'


Booth Martin wrote on 17/05/2007 09:39:50:

What bothers me is that dates don't round trip well. Does
March 31st
less one month, plus one month, equal March 31st?

It bothers me too, but I'm not sure there would be a sensible
way to implement month arithmetic so that March 31 could
round trip. Suppose that

a = 2007-03-31
b = a - 1 month + 1 month

If b = a, then you would just have another inconsistency.

c = a - 1 month
d = 2007-02-28

I think that we can agree that c = d. But then you have

c + 1 month = d + 1 month
(a - 1 month) + 1 month = (2007-02-28) + 1 month
2007-03-31 = 2007-02-28
.........................
uh-oh!

Dates arithmetic will never behave like integer arithmetic,
because 'months' and 'years' are not really consistently defined.

Attention:

The information contained in this message and or attachments
is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other
use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended
recipient is prohibited. If you received this message in
error, please contact the sender and delete the material from
any system and destroy any copies. Thank you for your time
and consideration.

Attention:

Le contenu de ce message et(ou) les fichiers ci-joints
sadressent exclusivement ` la personne ou -entiti ` laquelle
ils sont destinis. Ils peuvent contenir de linformation
confidentielle, protigie et(ou) classifiie. Il est

strictement interdit ` toute personne ou entiti autre que
le(la) destinataire
privu(e) de ce message dexaminer, de riviser, de
retransmettre ou de diffuser cette information, de prendre
une quelconque action en fonction ou sur la base de celle-ci,
ou den faire tout autre usage. Si vous avez regu ce message
par erreur, veuillez communiquer avec lexpiditeur(trice),
supprimer ce message et les fichiers ci-inclus de tout
systhme, et en ditruire toutes copies, quelles soient
ilectroniques ou imprimies. Nous vous remercions de votre
entihre collaboration.



--
This is the RPG programming on the AS400 / iSeries (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




This e-mail transmission contains information that is intended to be
confidential and privileged. If you receive this e-mail and you are not a
named addressee you are hereby notified that you are not authorized to read,
print, retain, copy or disseminate this communication without the consent of
the sender and that doing so is prohibited and may be unlawful. Please reply
to the message immediately by informing the sender that the message was
misdirected. After replying, please delete and otherwise erase it and any
attachments from your computer system. Your assistance in correcting this
error is appreciated.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.