Solved

Crystal Report Dateserial function

Posted on 2013-01-10
10
1,997 Views
Last Modified: 2013-01-12
I would like to obtain closed incidents between Jan 1, 2012 to Dec 31, 2012 using the Dateserial.  

I am using:

{Problem.CreatedDateTime} >=Dateserial(Year{currentdate}, month {currentdate} -12, 1 and {Problem.CreatedDateTime < Dateserial {Year{?End Date}), month({?End Date}), 1) and {Problem.Status} = "Closed".

I am very close.  I should have a total of 108 but I am coming up with 106.  I don't know was the ,1 after the 12 represent.  Could you help or redefine the formula.
0
Comment
Question by:cdmccoy
  • 5
  • 3
  • 2
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 38764788
Why are you using EndDate?  What value did you pass in?

DO you always want that range or is the range going to change based on the current date?

mlmcc
0
 

Author Comment

by:cdmccoy
ID: 38764869
The End date will change every month going to the prior month.  For instance, the End Date is 12/31/2012.

The range is going to change every month to the prior month
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 38765479
So you want a 12 month rolling count?

If EndDate is the date you want then use

{Problem.CreatedDateTime} >=Dateserial(Year(currentdate)-1, month (currentdate), 1) and {Problem.CreatedDateTime <= {?End Date} and {Problem.Status} = "Closed"

If you want the 12 months before today you can base it completely on the durrent date

{Problem.CreatedDateTime} >=Dateserial(Year(currentdate)-1, month( currentdate), 1 and {Problem.CreatedDateTime <= Dateserial (Year(currentdate), month(currentdate), 0) and {Problem.Status} = "Closed"

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 38766378
FWIW, the 1 argument in your DateSerial functions is the day of the month.  So, your formula is looking for CreatedDateTime >= (first day of the month, 12 months ago) and < (first day of the month and year in End Date).

 So, your starting date is the first day of the current month, last year.  For example, for any date this month (January, 2012), the starting date is 01/01/2011.

 Your ending date will, of course, depend on the End Date parameter.  For example, if you enter 12/31/2012 in the parameter, your formula uses 12/01/2012 as the ending date.

 James
0
 

Author Comment

by:cdmccoy
ID: 38766779
I need the formula to look at 12/31/2012.  Therefore my ending date is incorrect.  How do I get the ending date to look at 12/31/2012?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cdmccoy
ID: 38766781
can I use for ending date LastFullMonth?
0
 

Author Closing Comment

by:cdmccoy
ID: 38766892
Both solutions work.  I did not see the first comment by mlmcc before submitting my comment.  Thanks
0
 
LVL 34

Expert Comment

by:James0628
ID: 38767592
> can I use for ending date LastFullMonth?

 FWIW, if you want the ending date to be the end of the previous month, you could use LastFullMonth, but not by itself.  LastFullMonth actually produces a range of dates.  For example, today it would be 12/01/2012 to 12/31/2012.  So, you'd need to use Maximum to get the ending date in that range (the last day of the month).  Something like {Problem.CreatedDateTime} <= Maximum (LastFullMonth)


 Also, it just occurred to me that the time could be an issue.  Maximum (LastFullMonth) would give you 12/31/2012 12:00 AM.  Same thing for the formula that mlmcc posted, since it doesn't include a time.  If CreatedDateTime includes actual times, any time after 12 AM on the last day of the previous month won't be included.

 If CreatedDateTime includes actual times, you could change the formula accordingly.  For example, use {Problem.CreatedDateTime} < Minimum (MonthToDate) to look for any date before the beginning of the current month.

 James
0
 

Author Comment

by:cdmccoy
ID: 38767680
Ok -- to be on the safe side, I changed the report as suggested to:

{Problem.ClosedDateTime} >=Dateserial{Year(CurrentDat} -1, Month {CurrentDate},1) and
{Problem.ClosedDateTime} <= Minimum{MonthToDate} and {Problem.Status} = "Closed"

The Data is showing correctly.

Question... Within this same report I have another problem open and mlmcc has been diligently working with me to resolve.  It's posted and still open for a solution.  I also attached the report.  It's the same report in which we are working on.  To complete I need the graph within the report to reflect a rolling (Active) incidents.  Would you have a chance to review this open posted Question?
0
 
LVL 34

Expert Comment

by:James0628
ID: 38769584
I would change {Problem.ClosedDateTime} <= Minimum (MonthToDate) to {Problem.ClosedDateTime} < Minimum (MonthToDate).  IOW, use <, instead of <=.  Using <= would include any records with a time of 12 AM on the first day of this month.  I think you want <, to only include the records that are dated _before_ the first day of this month.

 I'll look at your other question, but I may not be of much help, since I've never actually used charts in my reports.

 James
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now