Can anyone help with the function for reporting the day before current date? I'm using Crystal 10. Being new to Crystal I can't seem to get the formula to work that I have. I want the report that I have built to display the day before's data. Thanks very much in advance!!DateAdd ('d',-1 ,CurrentDate )|||The database field that I pull the date from is the {Trips.tdate}, therefor it would be this?
{Trips.tdate} dateadd('d',-1 ,CurrentDate )|||Just go to REPORT -> SELECT EXPERT and in that write:
{Trips.tdate} = dateadd('d',-1 ,CurrentDate )|||I am getting an error stating "a string is required". It follows the =|||in trips, tdate is string|||This is what I have
{Trips.tdate} = dateadd('d',-1 ,CurrentDate )
I get a "number amount, currency amount, boolean or sting is expected here" Here being between the = and dateadd
I know now why I became a paramedic!|||You are comparing a string (which happens to look like a date to you) with a date.
In the field explorer, right click, show field type to check - should say string.
Convert your trips.tdate string to a date.
Alternatively, make sure you store dates as dates, not strings :)
So something like:
CDate({trip.tdate}) = dateadd('d',-1 ,CurrentDate )
To avoid having to do this throughout a report (if you use trip.tdate a lot) you can create a formula to return the string as a date and use the formula instead of the database field.
Still better to store it properly in the first place though!|||You are correct in the fact it is a string. I have no way of changing how the software captures the date. I pasted the following
CDate({trip.tdate}) = dateadd('d',-1 ,CurrentDate )
It now tells me that trip.tdate is an unknown field.|||You weren't supposed to blindly copy my typo! It's Trips (with an 'S') not trip.|||I got it, I got it!!!! Thanks everyone!!!!!!|||Thanks JaganEllis!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment