Date range formula
Post Author: Drumcode
CA Forum: Formula
Hello,
My first post, I'm a total newb using CR11, I hope you forgive me if I'm asking a very simple question here. Is there a generic formula for date range I could use in the page header based on the date range from selection expert? I can probably get away with just the text field up there, but it'd be nice to automate it on my other reports. Thanks for any help you can provide.
Jack
Post Author: Drumcode
CA Forum: Formula
Alright, so I've created the parameter fields for the date range. It pulls the data correctly but now, how do I make this date range visible in the page header?I want it to look this way:
Report Title Date Range: 00-00-0000 to 00-00-0000 Company Name Print Date
DataDataData----
Again, I can live with that date range to be a text object but how can I have it use the same data range as the parameter field?
Similar Messages
-
Current date in date range formula
I have a report where I only want to see records if the current date is between 2 dates on the report ( {@ Eff From} and {@Eff To} )
I will try to show example below:
Part A - Eff From 06-04-2007 Eff To 12-31-2020
Part B - Eff From 06-04-2007 Eff To 09-30-2008
Part C - Eff From 10-01-2008 Eff To 12-31-2008
In this example, I would only see Part A and Part B because currentdate is between the 2 dates.
Once currentdate is 10-1-2008, I would only see Part A and Part C.
Any suggestions?there is a fuction called currentdate
in the record selection you can use
if currentdate>= {@ Eff From} and currendate<={@Eff To} )
then true
you could also create parameters which will allow the user to select the dates. -
Passing DateArray or Date Range from formula result to Select Expert
Is there a way to pass Two (2) dates from a single formula to the Select Expert?
I calculate Beginning and Ending dates of periods ie: fiscal year to date, calendar year to date, last calendar quarter. I would like to pass both the beginning and end date to a formula in the Select Expert.
Please show code samples if possible.
ThanksIn your selection criteria, have code similar to this:
datevar begindate; // this is from your formula for date range
datevar enddate; // this is from your formula for date range
{database.datefield} in begindate to enddate;
Edited by: Sanjay Kodidine on Jun 27, 2009 11:43 AM -
Formula help - Group totals for more than one date range
Post Author: melcaylor
CA Forum: Formula
I need to show in 3 columns
inside of a grouping that totals an amount field based on a date
range that amount was posted. So for example:
Billy Bob in the state of MA made $5.5m total, $800k in the last 21 days, $400k in the last 14 days and $150k in
the last 7 days.
I assume this is possible but I
just donu2019t know what type of formula to write to make it work. For this
example, there are 2 tables u2013 user table and $$ table. The User table has
the user name, the $$ table has the pay date and the amount.Post Author: SKodidine
CA Forum: Formula
You only need simple formulae in Running Totals to accomplish this.
1. Group by Name
2. Create the following Running Totals:
2.1 A running total to sum the pay amount for all records, and resets on 'Change of Group' of Name.
2.2 A running total to sum the pay amount and for 'Evaluate' click on the radio button next to 'Use a formula' and then click on X-2 button next to it.
In the formula workshop window type a formula such as: {table.payment_date} in (currentdate - 21) to currentdate;
For 'Reset' click on the radio button next to 'On change of group' and pick the group name.
2.3 Create another running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 14) to currentdate;
2.4 Create the last running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 7) to currentdate;
Hide the details section and in the group footer place text boxes with appropriate text and insert these running totals to give you the numbers you want.
The only issue I see with this is if a person was paid yesterday a sum of $25, then it will show $25 for total, last 7days, last 14days and also for last 21days. At first look it might be mistaken for $75. -
Using Date Range parameter in Subreport Selection Formula
I have a subreport which includes this line in the selection formula:
{Production.Date} = {?Pm-?DateRange}
{?Pm-?DateRange} appears in the Subreport Links window, so it seems like it should work.
The DateRange parameter is set by the user in the Main report.
But the subreport returns no records.
I tried this:
In the Main report I created a StartDate and a StopDate field from {?Pm-?DateRange} .
Then in the subreport selection formula I used these two formula fields like this:
{Production.Date} >= @StartDate
and
{Production.Date} <= @StopDate
This works!
So I have found a workaround, but still, I don't understand why the original code {Production.Date} = {?Pm-?DateRange} returns no records.
Thanks,
ArtHi Art,
You cannot use a date range parameter directly in the subreport's record selection formula.
You'll need to create a formula in the Main report like this:
Minimum(?DateRange) //This gives the start date
Maximum(?DateRange) //This gives the end date
Then send these formulas as parameters to subreport for use in the record selection formula.
I think you've already got this figured out anyway!
-Abhilash -
Use formula for date range instead of parameter?
I am designing a Crystal report that will always pull records for the next full week.
Example: Today is 8/4, so I need the report to pull data for dates 8/11 through 8/15.
Currently, I am using parameters each time to run this report.
Is there a formula that could automatically pull this date range without using parameters in my report?
Any help is appreciated.
Thanks.This is actually not too difficult. Assuming you want to be able to run this on any date and get the "Next Full Week" starting on Monday (based on your date range above), here's what you could do:
1. Create a formula that I'll call {@StartDate}
NumberVar dow := DatePart('w', CurrentDate, crMonday) - 1; //Day of week, starting on Monday.
NumberVar days := 7 - dow;
CurrentDate + days
2. Create a formula that I'll call {@EndDate}:
{@StartDate} + 7
3. In the Select Expert, manually edit the selection formula to use these date formulas instead of the parameters.
-Dell -
Formula to return text answer from a date cell that falls within a certain date range
I have a cell, lets say B2 which has a date eg/ 21JUN14. I want to return which season this falls into eg "low", "shoulder", "peak" etc from 5 specified date ranges. thanks.
HI KJ,
Here's the syntax for VLOOKUP, taken from the Numbers Help files:
VLOOKUP(search-for,search-range,return-column,close-match)
Your assumption regarding the 2 is correct.
The other key value is Wayne's omission of the fourth argument, "close-match". When omitted, VLOOKUP will look for an exact match, but will accept a close match, defined as 'the largest value less than (or equal to) search-value.
close-match is the reason the table needs to include only the first date of each season, sometimes referred to as the 'threshold value'. Any date 'larger' than that, but less than the next season's starting date will be accepted as being in that particular season.
Note that the searched for dates include the year. The Seasons table will need to be updated regulrly. If you know the starting dates for more than one year, all can be entered as soon as they are known. The table will handle as many dates as are currently known (within a limit that's in the tens of thousands).
Regards,
Barry -
Function to list the month from a date range?
I would like to know what the function is that would take a look at a date range, and extract the month name
Here is how I would like it to come out:Hello
The following sample tables are along your original scheme using month name to filter the data.
2014 (excerpt)
A1 month
A2 =MONTHNAME(MONTH(B2))
A3 =MONTHNAME(MONTH(B3))
A4 =MONTHNAME(MONTH(B4))
B1 date
B2 2013-01-15
B3 2013-01-20
B4 2013-01-27
C1 category
C2 A
C3 B
C4 C
D1 amount
D2 100
D3 50
D4 20
January
A1 category
A2 A
A3 B
A4 C
A5 D
A6 E
A7 F
A8 G
A9 H
B1 totals
B2 =SUMIFS(2014::D,2014::A,C$1,2014::C,A2)
B3 =SUMIFS(2014::D,2014::A,C$1,2014::C,A3)
B4 =SUMIFS(2014::D,2014::A,C$1,2014::C,A4)
B5 =SUMIFS(2014::D,2014::A,C$1,2014::C,A5)
B6 =SUMIFS(2014::D,2014::A,C$1,2014::C,A6)
B7 =SUMIFS(2014::D,2014::A,C$1,2014::C,A7)
B8 =SUMIFS(2014::D,2014::A,C$1,2014::C,A8)
B9 =SUMIFS(2014::D,2014::A,C$1,2014::C,A9)
C1 January
C2
C3
C4
C5
C6
C7
C8
C9
Notes.
Formula in January::B2 can be filled down across B2:B9.
The target month name is defined in January::C1.
February table is the same as January table except for the value in C1.
And the following sample tables are using date per se instead of month name to filter the data. In this scheme, you don't need month column in source table but the retrieving formulae in destination table become more complex.
2014 (excerpt)
A1 date
A2 2013-01-15
A3 2013-01-20
A4 2013-01-27
B1 category
B2 A
B3 B
B4 C
C1 amount
C2 100
C3 50
C4 20
January
A1 category
A2 A
A3 B
A4 C
A5 D
A6 E
A7 F
A8 G
A9 H
B1 totals
B2 =SUMIFS(2014::C,2014::B,A2,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B3 =SUMIFS(2014::C,2014::B,A3,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B4 =SUMIFS(2014::C,2014::B,A4,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B5 =SUMIFS(2014::C,2014::B,A5,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B6 =SUMIFS(2014::C,2014::B,A6,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B7 =SUMIFS(2014::C,2014::B,A7,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B8 =SUMIFS(2014::C,2014::B,A8,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
B9 =SUMIFS(2014::C,2014::B,A9,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
C1 2013-01-01
C2
C3
C4
C5
C6
C7
C8
C9
Notes.
Formula in January::B2 can be filled down across January::B2:B9.
The target month is defined in January::C1, which can be any date in target month, e.g., 2013-01-01, 2013-01-20, etc. The formulae in B will retrieve data with date in range: 2013-01-01 <= [date] <= 2013-01-31.
February table is the same as January table except for the value in C1.
Tables are built in Numbers v2.
Hope this may help,
H
EDIT: Replaced the last table with the correct one. (Formulae in B are correct) -
CURRENT YEAR SALES DATE PARAMATER AND PRIOR YEAR SAME DATE RANGE
I am pulling data from a SQL view dbo.view that has current and historical SOP data by line. The date paramater is a date range, uppr date and lower date formulas are in the report. I need to include prior year SOP data for the same prior year date range in the detail. I have tried adding the view in twice with no luck, just duplications. Ultimately I want to supress the detail and only show the totals by customer so it is comparitive. Thanks for your help. Jayne
OK
lets simplify it
get a test data source with some simple dates in it.
get the report logic working.
it looks like you have the right formula ideas but lets go for
@upperthisyear
@upperlastyear
@lowerthisyear
@lowerlastyear
then assuming a date field of {table1.date}
the record selection would be
if (@upperthisyeare > {table1.date} and @lowerthisyear < {table1.date}) or (@upperlastyeare > {table1.date} and @lowerlastyear < {table1.date}) then 1 else 0
I would test this by using it as a formula field with the test data. -
How would you send a date-range parameter to a SQL sproc?
Team,
MY ENVIRONMENT
SQL 2005, Crystal Reports for Visual Studio 2005
MY PROBLEM
I am authoring both a sproc and a report, so I have full control over the design. I am a SQL expert and also a Crystal 8.5 expert.
I have done the Sproc-Report connection dozens of times.
Please consider along with me the sequence of creating a report based on a parameterized stored procedure.
My sproc header is shown here:
CREATE Procedure dbo.usp_DocumentActivityReport(
@Department NVARCHAR(50)
, @DateRange NVARCHAR(50)
) AS
SELECT Col1, Col2, Col3 FROM #TEMP
MY THOUGHT PROCESS
@DEPARTMENT is a string. That's easy.
@DATERANGE is a DATE RANGE and I don't know how to get Crystal Reports to prompt for a date range, so I used a String parameter knowing I can parse a specially formatted string, and knowing that I can use a formula to compute the string.
Step 1. Create the blank report, the {?Department} parameter, the {?CreationDateRange} report parameter, and the {@DateRangeText} conversion formula that converts {?CreationDateRange} to the specially formatted string.
Step 2. Test the stored procedure.
Tests pass; It returns data when I run it with values, with zero-length string values, and with NULL values.
Step 3. Tie the report to the stored procedure.
Adding the sproc directly creates two hard-wired, undeletable parameters, and returns data columns. That's no good because the user must supply the specially formatted string for the date range. So, I try using Add Command instead, with this syntax:
{call "EXP_TEST"."dbo"."usp_CorroDocumentActivityReport" (N'{?Department}', N'{@DateRangeText}')}
This code is accepted, but Add Command did not create any undeletable parameters at all. I guess that's OK.
But the worst part is that it does not show any output columns with data either! AAARGH!
Please assist with showing me the proper order to do these steps.
BTW, here's the VB Syntax formula for {@DateRangeText}:
Dim min As String
dim max as String
if HasLowerBound ({?CreationDateRange}) then
min = ToText(Minimum({?CreationDateRange}),"MM/dd/yyyy")
else
max = ""
end if
if HasUpperBound ({?CreationDateRange}) then
max = ToText(Maximum({?CreationDateRange}),"MM/dd/yyyy")
else
max = ""
end if
if IncludesLowerBound ({?CreationDateRange}) then
min = "[" & min
else
if HasLowerBound ({?CreationDateRange}) then min = "(" & min
end if
if IncludesUpperBound ({?CreationDateRange}) then
max = max & "]"
else
if HasUpperBound ({?CreationDateRange}) then max = max & ")"
end if
'formula = min & "..." & max
formula = "(1/1/2009...3/1/2009)"
sorry ... cross-posted per AmitLudek,
It sounds like you and The specified item was not found. think along the same lines! I have cross-posted for both of you now!
Please see Simple Sproc Parameters question
~ Shaun -
Possible to do limited date range changes in Calendar?
If I set up a filter, say, for days since my last sync AND I'm doing a two-way sync, will only those changes sincy my last sync be synced or will I lose everything not in that date range? Since I make changes to the calendar in Outlook and on the device this is especially important to me. This could save me a lot of time, but I don't want to lose any other calendar data
Also, I assume that I set the filter to use 'start date' and uncheck the box that says ' Delete from device any data that does not match the filter'. I am using DM 4.6 and OS 4.3
IrwinII
Please remember to "Accept as Solution" the post which solved your thread. If I or someone else have helped you, please tell us you "Like" what we had to say at the bottom right of the post.Hi Mark,
Yes, you can pass a date range value to the SUbreport!
Here's how its done:
1) Create a formula in the Main report; call it Start_date:
Minimum({?Date_parameter})
2) Create a second formula in the Main report and call it End_date:
Maximum({?Date_parameter})
3) Insert the sub-report and then Right-click the sub-report > Select Change Subreport links > Move the Start_date and End_date formulas to 'Fields to Link to' area and make sure you uncheck the 'Select data in subreport based on field' option.
4) Edit the sub-report (Right-click > Edit) and insert a Record Selection formula to include the parameters from the Main Report.
Go to Report > Selection Formulas > Record:
{date_field} >= {?Pm-@Start_date} and {date_field} <= {?Pm-@End_date}
Hope this helps!
-Abhilash -
How to get XLR to show BPs with no transaction data for a given date range
Hi -
I am building an XLR report that does a comparison of net sales data across two periods for a given sales employee's BPs.
The report has the row expansion:
FACT BPA(*) SLP(SlpName = "ASalesPersonNameHere") ARDT(Code = "ARCreditMemo", "Invoice") Group by BPA.CardName
and column expansions:
FIG(SO_TaxDate = @StartDate:@EndDate)
and
FIG(SO_TaxDate = @StartDate2:@EndDate2)
where @StartDate, @EndDate, @StartDate2, @EndDate2 are parameters that define the two ranges of dates.
The column formulas are, from left to right:
=ixDimGet("BPA", "CardName")
=ixGet("SO_DocTotal") <-- filtered by column expansion for first date range
=ixGet("SO_DocTotal") <-- filtered by column expansion for second date range
The report works fine except for one problem, I would like it to include BPs for which no transaction occurred in either date range as well.
Any help is greatly appreciated!
Thanks,
Lang RileyReally appreciate your feedback! Those are good suggestions. I should have mentioned that I had already tried both those suggestions.
Removing FACT on BPA in this case ends up returning all the BPs and not respecting the SLP(SlpName = "aName") part of the query.
Using **, i.e., * or #NULL, makes no change in the resulting data in this case. I had thought that ** would be the solution, but it didn't change the outcome. I still have BPs for which when their sales employee is used as the filter and they have no transactions for either date range, and yet they still do not appear.
I should further mention that the IXL query, as it now stands, does return BPs for which one of the periods has no data, just not both, and I have verified that applicable BPs with no transaction data for both periods do exist in my data set. It seems that perhaps the IXL query needs to be restructured? Please keep the suggestions coming including how this query might be restructured if necessary. -
How can I get the start and end of a date range?
Post Author: RobR
CA Forum: Formula
Greetings!
I have a report whose records are selected if a date field is within the date range returned by the LastFullWeek function. I want the header for that report to print the first and last dates in that range. I don't see a way to extract those dates from a date range. How do I do it?
Also, I think it would be nice to be able to walk through a date range using a for loop, something along the lines of the following:
for (thisDate in LastFullWeed)( do something;)
but I didn't see syntax like that in the help system. If I could do this, then I could get the first and last date. Is this possible?
Thank you!
RobRPost Author: SKodidine
CA Forum: Formula
If all you want is the starting date and ending date of the function LastFullWeek, then all you have to do is this:
minimum(LastFullWeek) & ' ' & maximum(LastFullWeek);
On a side note, from your post: for (thisDate in LastFullWeed) Whatcha smokin' Willis?? -
Sum an amount between a certain date range
Hello,
I am working out a home budget and want to know how to calculate what is due this month.
I have two columns - "Amount" and "Due Date". Some content for an example is:
Amount,Due Date
20,15/05/2009
300,16/05/2009
40,1/06/2009
What I want is a formula which will sum the total amount of items due within this months' date range. If the date range could be as automatic as "This Month" that would be great otherwise I would say IF "Due Date" between 1/05/2009 and 31/5/2009.
Is this possible?In column D, the formula is:
=YEAR(C)*100+MONTH(C)
In B8 and in B9 the formula is:
=SUMIF(D,YEAR(A)*100+MONTH(A),B)
Yvan KOENIG (from FRANCE jeudi 14 mai 2009 15:30:56) -
Regarding Date Range parameter
hello,
in purchase order, i want to pass date range parameter. For eg .
I want to fetch data from 21/11/2011 to 25/11/2011
how to pass parameter for this?? or do i need to create any formula??
if yes then how/???????
awaiting for soonest reply.hi,
you need to do this in the Formula workshop.
this formula {OPOR.DocDate} = {?DateRange}
{OPOR.DocDate} - this is the PO DocDate
{?DateRange} - this is what you have done in step #4 in my 1st post. in this example "DateRange" is the name of my Parameter.
Quote from you post
{OPOR.DocDate} = {?25/11/2011 to 30/11/2011} In this way should i write a formula??????
change this {?25/11/2011 to 30/11/2011} to the name of your Parameter. refer to step #4.
regards
Fidel
Maybe you are looking for
-
Installing Java EE on Windows XP.
I am new to Java EE and am having difficulty installing it. I am running Windows XP and was wondering if there's a step-by-step guide that covers which files I need to download and install in order to develop Java EE applications. Any help is appreci
-
Are following mass operations available in NW04(s) Portal?
Hi, Are the following mass operations available as standard feature/tool in NW04(s) Portal or do we have to build a tool to automate them? 1- Given a file with a list of Users and their associated Language(e.g. either english or french), perform the
-
Can random queue name used in EOIO ?
Hi, Friends: We have scenario: JMS -> PI 7.0 (SP13) -> ECC 6.0. Since we need to maintain the order of the transactions, EOIO setting need to be enabled. When enable EOIO in JMS sender, we specified random queue name saying "INT001" without registeri
-
Change Ship to party number for outbound delivery
Hi guys I have a problem We need to change Ship to party number for outbound delivery Any suggestions Any Table level changes posibility??? Thanks SAP MM
-
MacBook bluetooth firmware problem (and solution)
This is for the benefit of anyone who experiences the same problem as me. I updated several Macs today with the bluetooth firmware 2.0 update. All were OK but one MacBook, which would not restart at all, and gave 'three beep' tones on startup, indica