Sending date parameter the safest encoded way

Posted by OctavioOlguin on 11-Oct-2016 16:27

I have an appserver routine, that accepts a dataset with info about a procedure to execute, with parameters and stuff...

But now, I deviced some extra functions that it would be nice to have on this processor... the thing is I run out of parameters on the receiving procedure.  I'm just missing two dates parameters...

The solution I came is to stuff two dates in one char parameter:

ttBot.CharParam20 = string(date1) + "," + string(date2).

and on the called procedure, unstuff the two dates...

But I just wondered....

Being this program in ISO8859 page, and DMY...  the date will be stuffed like "30/10/16,31/12/16", what would happend sometime in future, when some customer on different date format tries to use that app...

What would be the safest way to send two date params to a program using one char variable?

(I´m in no position to expand the interfase of the called procedure)

using ABL to standard .p on appserver 11.3

Posted by James Palmer on 11-Oct-2016 17:01

Have a look at the ISO-DATE function.

Posted by Aidan Jeffery on 11-Oct-2016 18:02

An ABL date can also be converted to an integer:
  myint = INTEGER(TODAY).
And you can convert it back again using the DATE function:
  mydate = DATE(myint).
 
So maybe you could STRING the integer values of the two dates.
 

All Replies

Posted by James Palmer on 11-Oct-2016 17:01

Have a look at the ISO-DATE function.

Posted by OctavioOlguin on 11-Oct-2016 17:38

Just have to look the easiest way to turn them back...

Thanks!

Posted by Aidan Jeffery on 11-Oct-2016 18:02

An ABL date can also be converted to an integer:
  myint = INTEGER(TODAY).
And you can convert it back again using the DATE function:
  mydate = DATE(myint).
 
So maybe you could STRING the integer values of the two dates.
 

Posted by Stefan Drissen on 12-Oct-2016 02:47

I was wondering if that needed to be an int64, but dates still fit nicely in the 16 bit year address space [:)]

def var idate as integer no-undo initial 13689326.

message 
   date( idate ) skip 
   date( idate + 1 ) 
view-as alert-box.

Posted by Thomas Mercer-Hursh on 12-Oct-2016 10:10

You do realize that doing this kind of thing is pretty much guaranteed to bite you later?  Do what it takes to change the interface.

Posted by Eric Andruscavage on 12-Oct-2016 12:14

In version 9 I needed to store a date-time in an integer field, so I used:

v-datetime = int(today - 01/01/2005) * 1440 + (time / 60).  This is <= 8 digits well into the 22nd century.

These days I use ADD-INTERVAL(DATETIME (01/01/2005),v-datetime,'minutes') to get it back.

Posted by Eric Andruscavage on 12-Oct-2016 12:23

I'd agree, only I use a comma delimited list to pass parameters all the time. As long as the program is designed to accept 1 or more entries in the parameter.

Better than what I've seen in the past, i.e.:

def shared variable emp-ids extent 100.

do i - 1 to 100:

 if emp-ids[i] <> "" then do:

   [...]

 end.

end.

This thread is closed