1. Richard Donagrandi
  2. PowerBuilder
  3. Friday, 9 August 2024 17:10 PM UTC

Powerbuilder 2022 R3 Build 3356

If you have a datawindow default on a column of type datetime, the datetime doesn't populate on insert. -- I have tried datetime(today(), now()) and just today()... neither works.

You can recreate this by simply creating a new datawindow with external source, and adding two fields:

table(column=(type=datetime updatewhereclause=yes name=my_date dbname="my_date" initial="datetime(Today(), Now())" )
column=(type=number updatewhereclause=yes name=row dbname="row" initial="0" )
)

Insert a row... your date will not fill in.

 

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 9 August 2024 17:37 PM UTC
  2. PowerBuilder
  3. # Permalink

You have to use "today" without any parenthesis.

Comment
There are no comments made yet.
Richard Donagrandi Accepted Answer Pending Moderation
  1. Monday, 12 August 2024 15:48 PM UTC
  2. PowerBuilder
  3. # 1

Thanks, everyone...

Our program is over thirty years old, and has been worked on by about a dozen different programmers, all supposed Powerbuilder experts. I did a sweep, and fixed references in about twenty or so datawindows --  each datawindow pointed to nearly every programmer having used Today() or DateTime(Today(), Now()) through the years some objects being part of the program since PB 7 at some point. ... So I don't think I'm completely crazy thinking this may have worked at one time --unless every programmer in the last thirty years has made the mistake, and we're only now catching it. Granted, there were many more datawindows that used Today without the parens.

We're in the middle of switching databases from SQL Anywhere to SQL Server, so our regression testing is definitely doing their due diligence! 

Comment
  1. Chris Pollach @Appeon
  2. Monday, 12 August 2024 17:45 PM UTC
Hi Richard;

You are not crazy as the old format was created by PowerSoft & worked for decades that way. I would suggest that you open a support ticket for this issue. IMHO, it should work either way.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Sunday, 11 August 2024 17:36 PM UTC
  2. PowerBuilder
  3. # 2

Hi Richard,

John and Miguel are absolutely correct and while I don't have any docs for PB 3.x I do have PB 5.x docs and, for the most part, it is the same Help content that John provided.

I think the other important point here is to differentiate between setting an initial value in the painter, which is quite limited in flexibility, versus doing so in script in say, the Constructor event, for example. Doing so this way gives you much more flexibility if the initial value needs to change depending upon the circumstances or if you need to set a value that just can't be accomplished in the painter for some reason.

As long as you're returning a string (and the value you're "stringing" is the correct data type), then you shouldn't have any issues. Something like This.object.thedate.initial = String(RelativeDate(Today(), 42)) would work just fine.

HTH...regards,

Mark

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 9 August 2024 17:47 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Richard - 

PB Help can be, well, helpful:

Miguel is correct.

Best regards, John

Comment
  1. Richard Donagrandi
  2. Friday, 9 August 2024 17:51 PM UTC
Is this a change of behavior? -- Datetime(today(), now()) worked in previous versions... This issue came up during a regression test on something that worked previously.
  1. Helpful
  1. John Fauss
  2. Friday, 9 August 2024 18:39 PM UTC
I don't know. However, I did look up this property in the DW Programmer's Guide publication for all versions back to PB 9.0 and it has been documented as shown above consistently since then... and possibly earlier.
  1. Helpful
  1. Miguel Leeuwe
  2. Saturday, 10 August 2024 14:25 PM UTC
No, it's not a change of behaviour. It's been like this since at least PB 3.x

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.