1. William Preston
  2. PowerBuilder
  3. Thursday, 4 February 2021 19:42 PM UTC

Hi,

I would like to change the date format in a dw field from yyyy-m-d to m/d/yyyy, and have that format displayed regardless of the windows date format. How can I do this... Thanks

William Preston Accepted Answer Pending Moderation
  1. Friday, 5 February 2021 13:19 PM UTC
  2. PowerBuilder
  3. # 1

Hi Miguell,

Thanks for your help. You solution was correct, but my real problem was that the data window field was being treated as a string, even though it showed up as a "date" datatype in the dw painter. The solution was to edit the dw source, and change the column type from a char [] to a date. My version of powerbuilder is 2019 build 2082. 

Please note that the db field (MSSQL Server) is type "date".

Thanks,

Bill

Comment
  1. Miguel Leeuwe
  2. Friday, 5 February 2021 13:28 PM UTC
You're welcome Bill:

Sometimes - especially when copying columns from one datawindow to another - internally the id= values "scr*w up".

The "id=number" of a column shown on the dw, has to correspond to the order of the columns in the section:



table(column=(type=char(3) update=yes ... name=currency dbname="cc_currency.currency" )

column=(type=char(24) update=yes .... name=description dbname="cc_currency.description" )

column=(type=char(2) update=yes ... name=short_code dbname="cc_currency.short_code" )



for the column "currency" the corresponding id would be "id=1"

for "description" id=2

for "short_code" id=3



So maybe it's a good idea to check on all the columns having the corresponding internal id's in the dw source code. Or, even better, create the dw all over if that's less work than checking all the id values.

regards
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 5 February 2021 12:54 PM UTC
  2. PowerBuilder
  3. # 2

For me it works, except for the "StringField" which is of type string. It has to be of type date(time).

 

Comment
There are no comments made yet.
William Preston Accepted Answer Pending Moderation
  1. Friday, 5 February 2021 11:52 AM UTC
  2. PowerBuilder
  3. # 3

Hi,

 

Thanks for your response.

I have tried this. The result after setting the format to mm/dd/yyyy is the field displaying the text  “mm/dd/yyyy” instead of the actual date. I did not have this issue with powerbuilder 12 or previous versions.

 

Any help would be appreciated.

 

Comment
  1. Miguel Leeuwe
  2. Friday, 5 February 2021 12:39 PM UTC
This would happen probably because your "date" field is not really of type date. For the date format to work your field has to be of type Date or DateTime. It won't show your original format correctly either.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 5 February 2021 04:39 AM UTC
  2. PowerBuilder
  3. # 4

Open the datawindow

click on the column

go to the properties tab and click on the "format" tabpage

change the format to m/d/yyyy (or mm/dd/yyyy would be a better idea maybe?)

That's the format you see when you are NOT editing the field. There also and "Edit" tabpage where you can specify a 'mask' and/or 'edit format'.

Hope it helps,

MiguelL

Comment
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.