Answer

Running AS/400 query to find records based on date

Is there a quick way of running an AS/400 query to select records based on current sysdate? I know you can get the current date using the Current command, but I can’t figure out how to make this work.

Try the following AS/400 query to find selected records based on date.

In "Define result fields" :

Field Expression
CD CHAR(CURRENT(DATE))
CURDAT SUBSTR(CD, 1, 2) ||
SUBSTR(CD, 4, 2) ||
SUBSTR(CD, 7, 2)

Then use CURDAT in your selection. You may have to change the day/month/year sequence to match your date field.

You can also expand the query to compare days, for example, today and yesterday’s data, using the following:

YD char(current(date) - 1 DAYS)

YESDAT SUBSTR(YD, 1, 2) ||
SUBSTR(YD, 4, 2) ||
SUBSTR(YD, 7, 2)

More on AS/400 commands:

Note: This tip is a compilation of advice from various experts on our site.

This was first published in February 2012

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: