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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting the Date (a year from yesterday) 1

Status
Not open for further replies.

DonnaB

Programmer
Apr 23, 2001
34
AU
Hello,
I'm trying to select the output according to the date. I want everything for a year from yesterday. Would I want to be using "LastYearYTD"??
Hope you can help!
:)
 
No, YearToDate and LastYearToDate is all dates from the 1/1 to todays date.

If you just want one date you can use the DateAdd() function with a negative 1 for the year.

This assumes you have V8. For V7 you can download the new date functions which inlclude DateAdd():

DateAdd ('yyyy',-1 ,currentdate ) Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Thanks for your help Ken. I'm still having trouble though. :)

I want all records, dated from yesterday (but the year 2000) to yesterday (this year, 2001).
 
No you want the following selection formula:

{Datefield} in
DateAdd ('yyyy',-1 ,currentdate-1 )
to (CurrentDate - 1) Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
I get an error message that says:
"A number, currency amount, boolean or string is expected here."
Is the only thing I need to change in the formula the DateField to my DateField??
 
How about using formulas:

LastYear = Year(CurrentDate) -1
LastMonth = Month(CurrentDate)
LastDay = Day(CurrentDate) -1
LastYTD = Date(LastYear,LastMonth,LastDay)


 
Yes, one replacement with your field.
Where is the cursor after you get this error?
Do you have a true date field?
What version of CR are you running? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
The cursor is at the start of "DateAdd" in the formula, after the error is reported.
I'm not sure if it's a true date field, how can I find out? I am using Version 7 of Crystal.
 
The DateAdd function is not installed with V7 but comes with V8. You have to download the DLL that has this function from Seagate's Web Site if you want to use it with V7.


You could also use:

{Datefield} in
(CurrentDate - 366)
to (CurrentDate - 1)

This, however, would be one day short in a leap year. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Thank you so much Ken!!
I downloaded the DLL and it all works beautifully. :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top