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

Date() Powerscript Function

323 views
Skip to first unread message

panagiotismamatsis

unread,
Feb 16, 2009, 8:34:24 PM2/16/09
to
Dear all,
i had came across a very weird behavour using the Date()
powerscript function as follows :

I had a scenario in which i had to find the last day of a
month. I created a function to return an integer and as a
sole
argument i was passing it a date. Into the funstion i was
constructing the date as string using the month and the
year
of the argument date and i was testing using the IsDate()
function and as day i used "31" then "30" then "29" and
"28".
When IsDate() returned me a valid date that was the last
day
of the month. Now the weird part comes.....when i was
running
my program for the month February when the source code
reached the part where it was doing :
ld_date = date( '29/02/2009' ) then the local variable
instead of receiving the value "01/01/1900" for some
weird
reason received instead the value "29/10/2010" ! I had
never
came across something like this before !
The runtime i am using is PB 10.2.1.9004 and my program
runs
in a WindowsXP box with SP2. Have any of you had any
weird
incident using the date() funtion before ?

Thanks in advance,
Panagiotis Mamatsis.

Jerry Siegel [TeamSybase]

unread,
Feb 16, 2009, 11:33:40 PM2/16/09
to
I generalize the code for the last day of a given month (which could be 28,
29, 30, or 31) by taking the first day of the next month and calling
RelativeDate (-1). Much simpler than calculating based on month number and
leap year!

<Panagiotis Mamatsis> wrote in message
news:499a141f.223...@sybase.com...

panagiotismamatsis

unread,
Feb 17, 2009, 3:07:10 AM2/17/09
to
Hi to all and thank you very much for your prompt reply,
actually this is how i have done it my friend but my
question
is to why this is happening. :-) I just want to
understand the
why. :-)

Best regards,
Panagiotis Mamatsis.

Jeremy Lakeman

unread,
Feb 17, 2009, 6:48:00 AM2/17/09
to

Huh, that's an odd bug.
In PB 10.2.1 Build 9858 (yeah I know it's a bit old) and 'dd/mm/yyyy'
regional settings I get;

messagebox('',string(date( '29/02/2009' )))

---------------------------

---------------------------
20/02/2029
---------------------------
OK
---------------------------

panagiotismamatsis

unread,
Feb 17, 2009, 9:38:35 AM2/17/09
to

Hi Jeremy,
i am glad to find also another fellow developer having
the
same problem because i have another problem now related
to
the above mentioned one ! This "issue" with the date is
not
happening to all machines ! It is happening to some
machines !
i haven't quite understand the why yet..... I just want
to
understand the why !!!!! :-)

Best regards,
Panagiotis Mamatsis.

dhum...@gmail.com

unread,
Apr 16, 2009, 2:06:54 PM4/16/09
to
Hi ALL,

I too faced with the same problem and it started in jan 2009. One PC
uses Date correctly and another has error.
Did anyof you had any system updates recently.
I think some of the updates are messing up with date function.
Please let me know.

0 new messages