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" :
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:
- Use this cheatsheet to find some of the most commonly used AS/400 commands
- This list from Search400 has some more frequently used iSeries commands
- Test your knowledge of iSeries AS/400 commands using this WhatIs.com quiz
- Learn the basics about iSeries commands and how many programmers use them
- Check out a quick tip on finding AS/400 commands
Note: This tip is a compilation of advice from various experts on our site.
This was first published in February 2012