Q. I'm trying to do some Query/400 reports for end users. Is there anyway in Query/400 to get today's date? I'd like to use that instead of requiring the user to enter the date every day. Also, is it possible to ask the end user the date they want and then use the given date in the query?
A. That's two questions, and the answer to both is yes.
To use the current system date in a query, define a result field and make the expression CURRENT(DATE). This returns the date field in the format defined by QDATFMT. You can also use the MONTH, DAY, and YEAR functions to get the desired portion of the date. For example, to get the current month in numeric format, use MONTH(CURRENT(DATE)) for the expression. If you need to compare the date field to a character field, use CHAR(CURRENT(DATE)). For more information on these functions, press the Help key when the cursor is in the Expression field.
To allow your users to enter parameters for the query before it is run, use RUNQRY (your query lib/your query name) RCDSLT(*YES). This will display the record selection screen and allow them to make changes before the query is run.
For the complete answer with screen shots, see
http://www.iseriesnetwork.com/Resources/ClubTech/TNT400/bo400ng/as400qrytdy.htm