2

I am newbie in Progress and I've Trouble in date function Progress 4gl.

Example I have string value = '2016 '.

How do I put that value into a date in Progress?

Example:

def var xx as char.
def var xq as date.

ASSIGN 
  xx = '2016'
  xq = DATE(01/01/xx).
Jensd
  • 7,886
  • 2
  • 28
  • 37
Prabu Karana
  • 302
  • 1
  • 4
  • 15

1 Answers1

4

While it is possible to write

ASSIGN 
  xx = '2016':U
  xq = DATE('01/01/':U + xx)
.

I would prefer

ASSIGN 
  xx = '2016':U
  xq = DATE(1,1,integer(xx))
.

(The first example is dependent on the current date format. If you look up the DATE function in the OpenEdge Help you can see that DATE ( month, day, year ) is valid, too.)

idspispopd
  • 404
  • 3
  • 10
  • Add error handling! You always need to check input and/or output when typecasting. A simple added NO-ERROR and validity check (xq <>?) could do it in this case. – Jensd Oct 06 '16 at 05:55