Solved

# Crystal Last full year & YTD Last full month

Posted on 2012-04-13
Medium Priority
3,856 Views
have several running totals that I need to add a formula for dates and cannot figure out the syntax.

Database field:  invoicedate
Format: mm/dd/yyyy
Formula 1: Need ability to do the following but have it put then year in dynamically so I dont have to always go in and update the year.
{oeeh.invoicedt} in Date (2011, 01, 01) to Date (2011, 12, 31)

Formula 2: Need formula to allow me to get current YTD to last full month. For example if today is 4/13/2012 it need to put the following:

{oeeh.invoicedt} in Date (2012, 01, 01) to Date (2012, 03, 31)
0
Question by:kelsanit
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 5
• 3
• 3

LVL 101

Expert Comment

ID: 37843514
Last year
Year({oeeh.invoicedt}) = Year(CurrentDate) - 1

This year full months
{oeeh.invoicedt} in Date (Year(CurrentDate), 01, 01) to CurrentDate - Day(CurrentDate)

mlmcc
0

Author Comment

ID: 37843898

Last year full months:
for example: if today is 4/13/2012 it woudl pull the following dates

1/1/2011-3/31/2011.

I am testing the others you sent but appear to be working good! thank you
0

LVL 18

Accepted Solution

UnifiedIS earned 2000 total points
ID: 37844039
Just reduce the years by 1 like this:

{oeeh.invoicedt} in Date (Year(CurrentDate) -1, 01, 01) to DATEADD(year, -1, CurrentDate - Day(CurrentDate))
0

LVL 18

Expert Comment

ID: 37844289
If possible, mlmcc should get some of the points too, although he has plenty...
:)
0

Author Comment

ID: 37844568

I am having problems with the formulas and the data it is pulling. both formula 1 & formula 2 are pulling the same data\numbers

Formula 1: Year({oeeh.invoicedt}) = Year(CurrentDate) - 1

Formula 2: {oeeh.invoicedt} in Date (Year(CurrentDate) -1, 01, 01) to DATEADD(year, -1, CurrentDate - Day(CurrentDate))
0

LVL 18

Expert Comment

ID: 37844707
Where are you putting the formulas?
0

Author Comment

ID: 37848894
in the running total formula section.
0

LVL 101

Expert Comment

ID: 37849104
It should be used as the record filter.

If you are using them in the evaluate when part of the running total then you need to use the formulas I provided or split the other into last year and this year to date.

This gets all the records for last year
Formula 1: Year({oeeh.invoicedt}) = Year(CurrentDate) - 1

This gets all records for last year through a year ago last month
Formula 2: {oeeh.invoicedt} in Date (Year(CurrentDate) -1, 01, 01) to DATEADD(year, -1, CurrentDate - Day(CurrentDate))

To get this year to date for full month
Formula 2: {oeeh.invoicedt} in Date (Year(CurrentDate) , 01, 01) to CurrentDate - Day(CurrentDate))

mlmcc
0

Author Comment

ID: 37850894
all formulas are valid except formula 2 which gives me an error

"Not enough arguements have been givent ot his function"
0

LVL 101

Expert Comment

ID: 37851568
Try

{oeeh.invoicedt} in Date (Year(CurrentDate) -1, 01, 01) to DATEADD(year(CurrentDate) , -1, CurrentDate - Day(CurrentDate))

mlmcc
0

Author Comment

ID: 37860751
it now says a string is required here and highlights the following area in the formula

year(CurrentDate)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirementsâ€¦
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearlyâ€¦
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increasedâ€¦
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can reâ€¦
###### Suggested Courses
Course of the Month15 days, 5 hours left to enroll