Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

relativedate() problem

276 views
Skip to first unread message

Martin

unread,
May 7, 2001, 8:23:35 AM5/7/01
to
when I try to add a number of days greater than integer to a date
relativedate()- function in a script doesn't work correct

e.g.: relativedate(date('1899-12-30', 36000)) -> returns 17.02.1819

-> should return approx. 30.12.1997

in a computed field in a dw it works, in a script it doesn't


Bruce Armstrong [TeamSybase]

unread,
May 7, 2001, 12:06:04 PM5/7/01
to
When you use it in a computed column, you are using a datawindow function
rather than a PowerScript function. The PowerScript version of RelativeDate
only takes an integer. There is a CR pending on an enhancement request to
have it support longs (CR# 160898).

On Mon, 7 May 2001 14:23:35 +0200,
in powersoft.public.powerbuilder.powerscript

Bruce Armstrong [TeamSybase]
http:\\www.needhim.org

---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp

Michael Walker

unread,
May 7, 2001, 12:13:49 PM5/7/01
to
Martin
Because it does work in the datawindow you might want to report that to
Sybase. However, the help says that the argument is an integer so in truth
the datawindow shouldn't work either.

FWIW PowerBuilder doesn't complain about an overflow of datatypes. For
instance.

int li_Test
li_test = 32767 + 1

li_Test will be equal to -32768. The integer loops to it's bottom limit then
starts counting up. So 36000 would give you something like -29535 which is
why you get a date before your relativedate. To get around this you can put
you code in a loop and execute it as many times as necessary.

Good Luck

Michael Walker
Cascadia Software

Jerry Siegel

unread,
May 8, 2001, 9:28:09 AM5/8/01
to
It looks like the constant 36000 is compiled as a long, but the cast to
integer wraps instead of throwing an overflow error. I would take advantage
of polymorphism and write a function relativedate (date, long).
Just out of curiousity, why do you need to go ~100 years ahead?


Xavier Colmant wrote in message ...
>relativedate(date, int) takes an integer as 2nd argument. In the script
the
>integers are defined as:
>16-bit signed integers, from -32768 to +32767. 36000 being larger than the
>limit, you are in fact sending a negative number to relative date...
>
>In the datawindow integers are probably 32 bits long...
>
>Frankly, right now I cannnot think of a nice way of getting around the
>problem:
>Use a long. If value greater than the limit, split the long in 2 (or
more?)
>int, and do 2 calls to relativedate().
>
>Xavier
>
>"Martin" <m.kalt...@xpoint.at> wrote in message
>news:oVB7dOv...@forums.sybase.com...

Xavier Colmant

unread,
May 8, 2001, 7:34:27 AM5/8/01
to
relativedate(date, int) takes an integer as 2nd argument. In the script the
integers are defined as:
16-bit signed integers, from -32768 to +32767. 36000 being larger than the
limit, you are in fact sending a negative number to relative date...

In the datawindow integers are probably 32 bits long...

Frankly, right now I cannnot think of a nice way of getting around the
problem:
Use a long. If value greater than the limit, split the long in 2 (or more?)
int, and do 2 calls to relativedate().

Xavier

"Martin" <m.kalt...@xpoint.at> wrote in message
news:oVB7dOv...@forums.sybase.com...

0 new messages