How to compare months of two dates in crystal report - date

I have seven dates on my crystal report.I need to compare month of each date with the date the report is made to run(#Datebeg is the field for report date).
I am using formula on my report as
if month({Date1})=month(cdate({#Datebeg})) and
month({Date2})=month(cdate({#Datebeg})) and
month({Date3})=month(cdate({#Datebeg})) and
month({Date4})=month(cdate({#Datebeg})) and
month({Date5})=month(cdate({#Datebeg})) and
month({Date6})=month(cdate({#Datebeg})) and
month({Date7})=month(cdate({#Datebeg}))
then (H1+H2+H3+H4+H5+H6+H7) else 1.
The output I am getting is 1,each time.The months are not getting compared at all.If I put OR instead of AND,that gives me sum of all H(1..7).
Please help me with the comparison.
Thanks in advance.

go ahead and create 7 formulas and put a condition per formula, for example:
#Formula1
month({Date1})=month(cdate({#Datebeg}))
#Formula2
month({Date3})=month(cdate({#Datebeg}))
so on and so forth. Place those formulas in you report header and run the report. In that way you can see the behavior of each condition and troubleshoot it. Those formulas are going to return True or False, True when they meet the criteria and False if they don't.
Hope that helps!

Related

Crystal Reports 2011: Calculate the number of times a value occures and the number of days in between

It occurs to me that I might have been able to find the answer to this but so far i've come up short. Also, I am pretty new to Crystal Reports (2011) so please forgive my ignorance if this is something I've missed. Here's the issue:
I have a report where I am pulling the number of times a value happens for a specific target, specifically how many times a specific procedure happens for a person within a specified date range. I have the results grouped by person.
I show the person, the procedure code and the date the procedure happend within that group.
What I NEED to do now, is to figure out how to return some type of visual indicator that there is at least 3 days in between each procedure for each person.. example..
[GROUP #1 NAME]....................[PROC_CODE]......[PROC_DATE]
[{Last_Name}, {First_Name}].....PROCEDURE..........PROCEDURE DATE
(Please forgive the "....." as I was trying to space out the headers and results)
Having said all that, the "Procedure Date" I would like to show up in RED if the next result within the group (by person) falls within 3 or less days from the last date. I am really hoping this makes sense to someone. Thank you in advance for your help!
create a formula called "DateDiff": DateDiff("d", {Proc_Date}, previous({Proc_Date}))
then in your Section Expert, choose the group that your data is in. Click the color tab. Choose the "x-2" formula button and enter: if {#DateDiff} > 3 then crred else crnocolor
edit so your next group doesnt pick up the last value:
if ({group1_field} = previous({group1_field})) then
if {#DateDiff} > 3 then crred else crnocolor
else
crnocolor

Adding a / between numbers in crystal reports

I have a date field that shows as CYYMMDD. To get rid of the century I have just subtracted 1000000 to show the date as YYMMDD ex. 150814.
Now I want to add / between the numbers to show as 15/08/14.
How do I do this in the formula?
Thanks in advance!
There are few things to be considered here.
Simply right click on the date field once you place the same in crystal report, you will get options to format data. You can choose whatsoever suits you.
In case you go by your approach for substracting the number..., you can convert the number into strong and then can play with it.
Posting the links for the second point help.Split the number and modify in Crystal

Crystal Report: Get Minimum Date

I have this concern using Crystal Report which I am not really familiar with. Here's my scenario:
I have an existing report to update, I need to add a column (ETA) which has a datetime value. It may return more than one rows per Item No, I need to get the minimum date only per Item No from the result rows.
I already tried some solution mentioned here http://scn.sap.com/thread/1952829 but found no luck.
I used a suppression formula for the Details section of the report, but haven't succeeded yet.
IF {TableName.DateField} = Minimum({TableName.DateField}) THEN FALSE ELSE TRUE
Any possible things you can suggest me to try? Thanks in advance for this :)
good to get this value from sqlserver side. you just create a function which return a single data (minimum date).
If you wish in crystal report side, it is something you make loop of hundred for a single row display. You can use running total field for this.
Select the field , select summary type and put into the detail section.
or you can create a formula with group name option like
Minimum({TableName.DateField})
http://scn.sap.com/thread/1952829
http://businessintelligence.ittoolbox.com/groups/technical-functional/businessobjects-crystal-l/unable-to-filter-based-on-the-first-date-in-list-of-dates-4912881
please check
Running total field gives options for Min, Max, etc. but not Sum
http://flylib.com/books/en/4.229.1.28/1/

Troubles with IsNull Crystal Reports

I'm using Crystal Reports 12.3 and Peachtree Accounting 2012 to manage some database. My task now is simply make a report that contains customers that have not placed orders in last 30 days. I'm new to it so I'm asking your help.
My first trying was to use this formula (I'm doing all my stuff in Formula Editor -> Record Selection):
not ({Customers.LastInvoiceDate} in Aged0To30Days)
Everything seems to be fine except null values. I need to include in report records with null values. So I rewrite the formula to:
not ({Customers.LastInvoiceDate} in Aged0To30Days) OR IsNull({Customers.LastInvoiceDate})
But in Peachtree Accounting 2012 I'm seeing a customer with a blank LastInvoiceDate field which is not in report.
Is there some kind of bug in my last formula? Or is there some "other" black values for DateTime type?
You should always check for nulls first, so try reversing the second formula to
isnull({Customers.LastInvoiceDate}) or not({Customers.LastInvoiceDate} in Aged0To30Days)
If Crystal encounters a null and it is not explicitly handled first, then the rest of the formula will crap out and not evaluate. Another way to get around this is to tell Crystal to use 'Default Values for Nulls' instead of 'Exceptions for Nulls' in the Formula Workshop (It's a dropdown setting in the Formula Workshop toolbar).
length(trim({Customers.LastInvoiceDate})) = 0
One statement with no need for isnull function and OR operator.

Crystal reports: using summary field in formula / summing time field in formula

In crystal reports I want to show the sum value of time objects, i.e. An employee worked in one month three days and on each day a variable amount of hours.
Is there anyway to sum a time field?
Or as a workaround I could use the time field as an integer, sum this and display. But then I would like to change the display format by using a formula. I cant find a way to include summary fields in a formula...
Thanks in advance
PS I am using CR 2011 (just the program not through VB or anything).
You cannot sum a date/time field. You will have to use datediff("n",{datetime1},{datetime2}) to get a time interval between two date/time fields in minutes.
To use a summary function in a formula, you can use this sum({#YourMinutesFormula},{FieldYouAreGroupingOn})
You may omit the second parameter if you want the summation over the entire report instead of a grouping level. Check the Crystal Reports help file for more details on Sum().