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!

ytd/lastyearytd

Status
Not open for further replies.

raghu55

Technical User
Oct 2, 2005
45
US
hello all,

I am using crystalreports9 and oracle 10g.
I am little confused with ytd/latyearytd.
Below iam giveing all the details,please look on that

report run for monthly.

parameters: start date, end date
groupby: doe_id
sortby: tot_amt_ytd
database field is: di_amt.

reportcolumns: selection/derivation
1)tot_amt_ytd select if loan_type in
(sf,su) for current year
ytd ending on to date.


2)tot_amt_org select if loan_type in
(sf,su)for previous month.


i have a formula fields like:
1)from date:
if {?start-date} = date(1900,01,01) then

minimum(LastFullMonth)
else
{?start-date}

2)to date:
if (?end date) = date(1900,01,31) then
maximum(LastFullMonth)
else
(?enddate}

3)select by range:
if {?start-date} = date(1900,01,01) then
{TABLE.DATE} in LastFullMonth
else
{table date} in {?start-date} to {?end-date}

my question is when i run the report using default parameters it should give tot_ytd_amt from starting of the year to enddate.

ex: if i run the report today it should give tot_ytd_amt from jan 1 2006 to mar 31 2006.

if i run the report, jan 2 2006 it should give last year tot_ytd_amt i.e(jan 1 2005 to dec 31 2005).


for second field tot_amt_org
it should give amt for lastfull month.
i.e only for (mar 1 2006 to mar 31 2006)

when i run the report jan 2 2006
it should give tot_amt for the month (dec 1 2005 to dec 31 2005).

help requested...







 
If your intent is to get the last year YTD for the same period as this years YTD, then try the following in the record selection formula:

{table.date} in yeartodate
or
{table.date} in dateadd("yyyy",-1,(minimum(yeartodate)) to
dateadd("yyyy",-1,(maximum(yeartodate))

Then add criteria to each aggregate formula similar to the above code to qualify each.

Last month would be the same if you intend to get it for the previous year, the key is to use the minimum and maximum.

-k
 
thanks.

but its giving records up to last year march 31 2005, i need up to dec 31 2005.
 
Then you don't want lastyearytd, which is what your post subject stated.

Try:

{table.date} in cdate(year(currentdate)-1,1,1) to
maximum(yeartodate)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top