How do I parse out a timestamp ISO format into a date field

5 pts.
Tags:
ISO
Query/400
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

In RPG it would be something like this
DateFld = %date(%subst(%char(TimeStamp):1:10):*ISO)

In Query, you should just be able to substring the 1st 10 chars

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Vatchy
    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.
    1,410 pointsBadges:
    report
  • Gg1
    There is also the BIF called %subdt. For instance in your case to extract the date you have yy = %subdt(timestamp:*y)
    45 pointsBadges:
    report
  • TomLiotta
    ...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
    125,585 pointsBadges:
    report
  • NullFields
    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.
    880 pointsBadges:
    report
  • PGMBOB
    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
    1,150 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following