Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default prompt value as current year

Status
Not open for further replies.

KidFix

Programmer
Feb 7, 2002
60
US
I need to filter my report by year, so I have a prompt, but I want the default value in the prompt dialog box to show the current year when the report is accessed. How can I do this? Also how can I filter on a year when I'm using date fields since they're not the same format?
i.e. 2001 <> 04/12/01 but it needs to!!

Hope that made sense
Thanks in advance
 
If you delete any and all default values from a date prompt, it will default to today's date when the report is executed.

You could also crate a number parameter with a default value of 2001, 2002, or whatever, and then put the following in your record selection formula:

Year({datefield}) in {?Parameterfield}

I hope this helps Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Thanks for the reply, but its not quite what I was after. The problem I'm having is that i want the user to input a four figure year value i.e. 2002 and then use this to filter all dates for that year i.e. 03/09/02, 20/04/02 etc. the problem being the date field uses only two numbers for the year so I need to do some converting. And how can you get the current year to appear as the default prompt i.e. default to '2002'

Thanks
 
Please re-read my post. If you do what it says, Crystal will prompt for a 4 digit year and the formula I gave you will restrict the report output to the year the user inputs into the report when it executes.

To make a default value, simply hit the &quot;set default values&quot; button when you create the parameter field. There is no way to make it automatically default to the &quot;current&quot; year, however, you will have to manually edit the parameter field once a year to do this.

Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Thanks, but surely if the fild uses a two digit year (i.e. 02 rather than 2002) then it won't be able to find 2002 in the date, and if it can what is to stop it deciding 02/02/01 is in the year 2002 when it isn't?

Thanks very much for your time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top