Is there a quick way of running an AS/400 query to select records based on current sysdate? I know you can get...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
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.
Dig Deeper on iSeries SQL commands and statements
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.