0
Votes
Undo
  1. Ramendra Singh
  2. PowerBuilder
  3. Tuesday, 6 August 2019 07:31 AM UTC
Hi Gurus We have an application where all the date fields are masked DD/MM/YY and when we enter the data 31/01/50, it converts in 31/01/1950 rather than 31/01/2050. Till year 49 it's fine and convert into 2049. Although if I change the masking to YYYY, it saves the value correctly. As there are too many date filed, I was curious to know if this can be managed with some configuration in the application to auto convert dates to 2050. thanks Ramendra
Accepted Answer
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 6 August 2019 12:11 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Ramendra,

as you probably know from PB doc

"If the year is two digits, the assumption of century follows thisrule: for years between 00 and 49, the first two digits are assumed to be20; for years between 50 and 99, the first two digits are assumed to be19. If your data includes dates before 1950, such as birth dates, alwaysspecify a four-digit year to ensure the correct interpretation."

Now, how do you work around ?

If your DW or edit fields inherit from a common ancestor, say u_dw or u_em or u_sle (do you remember pfc_u_dw from PFC lib?) you can just add code below (for the DW case)

event itemchanged;
If Upper(dwo.type) <> 'COLUMN' Then Return
If Upper(dwo.coltype) = 'DATE' Then
  Date ld_date
  ld_date = Date(data)
  // now take the year and add 50
End If
end event

Best,

.m

Comment
  1. Ramendra Singh
  2. Tuesday, 6 August 2019 12:30 PM UTC
Hi Marco



Thank you for your valuable inputs,I believe your recommendation should resolves the problem.



Regards

Ramendra
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 8 August 2019 13:12 PM UTC
  2. PowerBuilder
  3. # 1

Hi Ramendra,

To sum up Marco's and Matthew's answers:

Custom 2-digit year behavior in your PB app may make it inconsistent with Windows generic behavior. Be careful!

HTH /Michael 

Comment
  1. Ramendra Singh
  2. Tuesday, 13 August 2019 04:10 AM UTC
Hi Michael



Thank you for highlighting it, I will do further research before implementing any of the solution.



Regards

Ramendra

  1. Helpful
There are no comments made yet.
Matthew Balent Accepted Answer Pending Moderation
  1. Tuesday, 6 August 2019 11:44 AM UTC
  2. PowerBuilder
  3. # 2

You may wish to check the Regional Settings within Windows for the 'Short Date Style'.

Comment
  1. Ramendra Singh
  2. Tuesday, 6 August 2019 12:24 PM UTC
Thank you Matthew for your valuable input, I will give it a try and check the outcome.



Regards

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