Reputation: 1367
I've got a buffer which contains a mix of data, number and character fields. I am getting the displaying the values of the fields, but for some reason date fields return "?" when I try to add them to a string.
I still get ? even if I do
ASSIGN lvString = lvString + STRING( hField:BUFFER-VALUE ).
I've also tried assigning the BUFFER-VALUE to a local DATE variable, and converting that to a string, but that doesn't work either - still ?.
However if I use the STRING-VALUE attribute, it works fine.
How do I get the value out as a date field, rather than just a string?
Upvotes: 3
Views: 3344
Reputation: 102
There are two ways that you can use to achieve your needs. One is to use directly the table buffer and the other is to use an QUERY
handle.
First example using a buffer directly from a table (or a TEMP-TABLE, doesn't matter):
DEF VAR dateVar AS DATE NO-UNDO.
FIND FIRST job NO-LOCK.
dateVar = DATE(BUFFER job:BUFFER-FIELD('dt-job'):BUFFER-VALUE).
MESSAGE dateVar
VIEW-AS ALERT-BOX INFO BUTTONS OK.
Second example using a query handle:
DEF VAR dateVar AS DATE NO-UNDO.
DEF QUERY qrJob FOR job.
OPEN QUERY qrJob FOR EACH job.
QUERY qrJob:GET-FIRST().
dateVar = DATE(QUERY qrJob:GET-BUFFER-HANDLE(1):BUFFER-FIELD('dt-job'):BUFFER-VALUE).
MESSAGE dateVar
VIEW-AS ALERT-BOX INFO BUTTONS OK.
As Tim Kuehn said you can substitute 'dt-job'
by # of field in the query if you know its position inside the query. I could used BUFFER-FIELD(2)
in substitution of BUFFER-FIELD('dt-job')
because dt-job
is the #2 field in my query. Keep in mind that use the FIELDS
clause in a FOR EACH
or in an OPEN QUERY
statement changes the order of fields in query. Generally, for browsers only available the columns fields specified in FIELDS
section, in order.
These might work for you. It's important to say that BUFFER-VALUE
always returns a CHARACTER
data type and because of this you need to use DATE
statement for data conversion.
Hope it helps.
Upvotes: 1
Reputation: 3251
The standard form for getting a data of the field's data type is
buffer table-name:buffer-handle:buffer-field("field-name"):buffer-value.
for arrays it's:
buffer table-name:buffer-handle:buffer-field("field-name"):buffer-value[array-element].
You can also substitute a field # for "field-name" to get the buffer field handle.
Upvotes: 0