Ask the Expert

The field for the date in the database

In my database file I have a field for century and a field for date. The date field is in format YYMMDD. I want to print the date in a query in the format of MMDDCCYY with editing(if possible). Fields before converting 20 010426, fields after 04/26/2001. Is there a way to do this in Query/400?


In order to convert and format the fields, you must use result fields in your query. Give an century field "CC", and a date field "YMD", you need 2 fields (as the expressions won't fit on one field).

Result Field: Expression:

 MMDD           substr(digits(ymd),2,2) ||      
               '/' || substr(digits(ymd), 5, 2)

MMDDCCYY       mmdd || '/' || digits(cc) ||    
               substr(digits(ymd), 1, 2)     

That should do it.
John


This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to: