How do I parse out a timestamp ISO format into a date field? This is how the field looks:
Timestamp ISO Format 2008-10-08-12.13.52.412000
Here is the description of the field:
Field From To Length Type Description
XXXXXXX 57 82 0 Z Timestamp ISO Format
I need to get the 2008-10-08 into a date format so that I can match it and pull in specific dates only.
Thank you.
Software/Hardware used:
ASKED:
October 21, 2008 5:20 PM
UPDATED:
September 4, 2010 4:02 AM
It the date field is a true date field – type D – then just move the timestamp field to the date field and it will work correctly.
There is also the BIF called %subdt. For instance in your case to extract the date you have
yy = %subdt(timestamp:*y)
…to extract the date…
The %subdt() BIF does not extract a date from a timestamp field. It can extract a component of a date such as the year or the month. To get a full “date”, it would be necessary to extract the three year/month/day components and combine the three results into the required form.
As Vatchy suggested, simply assigning the timestamp value to a DATE field would be much cleaner.
Tom
In cobol, if the from and to dates are defined as date formats TIMESTAMP and YYYY-MM-DD respectively, then it’s just a simple move statement.
Tom is right, %subdt can get parts of a date.
%date( ) can work with numeric, character or timestamp fields
D Dateval D (default is ISO
dateval = %date(timestamp)
dateval is a date field
YYMMDD= #CHAR(dateval:*YMD0) 100903 character
YYMMDD= #CHAR(dateval:*YMD) 10/09/03 Character
YYMMDD#= %DEC(%CHAR(dateval:*YMD):*YMD0)) 100903 numeric
Good Luck
PGMBOB