Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Looking for a date range formula Post Reply Post New Topic
Author Message
CindyS
Newbie
Newbie
Avatar

Joined: 29 May 2013
Location: United States
Online Status: Offline
Posts: 7
Quote CindyS Replybullet Topic: Looking for a date range formula
     Posted: 03 Dec 2014 at 6:11am
You all have been a great help in the past, thought I'd give it a go again. This time...I'm looking for a formula that will allow results of one field to be based on a date range in another field.
Scenario: A customer can have many products on their invoice. Invoices are produced on the anniversary of the date of when the product was added. Meaning, if the product was added to the customer on 10/2, it would appear on the invoice for 11/2.  The invoice table has an 'issue' date. The products table has a 'bill to' date. I would like to pull just the products that would have appeared on an invoice for a particular month. The problem is, a product could have been added to the customer after that month's invoice was produced so using the same date ranges for 'issue date' and 'bill to' date won't work. I would like to somehow have the product 'bill to' date either match the invoice 'issue date' or be within the previous 30 day range of the invoice table's 'issue date'. Example: For Nov, a customer has an invoice issued on 11/2. That means the products on that invoice would have a 'bill to' date of 10/2 thru 11/1. I have tried various different syntax of formula's I have found around the web...Aged0to30days, etc. I hope you can help me out and that I provided enough info for a resolution.
Thanks a bunch, Cindy
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Dec 2014 at 6:52am
are these handled in different tables and you are trying to use the condition to join on?
aeryour examples all Month/Day and no year becuase the these are annual recurrances?
can you write a command or stored proc as your data source?
IP IP Logged
CindyS
Newbie
Newbie
Avatar

Joined: 29 May 2013
Location: United States
Online Status: Offline
Posts: 7
Quote CindyS Replybullet Posted: 03 Dec 2014 at 7:26am
Thanks for getting back to me.
Yes, different tables, the "issue date" is in the invoice table, the "bill to" date is in the products table. They are joined successfully. The format for both dates is mmddyyyy hh:mm:ss. Invoices are issued monthly. Unfortunately,  I'm not CR savvy enough to write a stored procedure.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Dec 2014 at 10:15am
I am assuming you are grouping this on some specific field and then trying to limit the rows within htat grouping to meet your conditions.
can you post sample data and explain what you want included or exclude with that sample?
IP IP Logged
CindyS
Newbie
Newbie
Avatar

Joined: 29 May 2013
Location: United States
Online Status: Offline
Posts: 7
Quote CindyS Replybullet Posted: 03 Dec 2014 at 10:36am
Yes, I have grouped by invoice number and need to remove those products with a date newer than the invoice issue date. I think part of the problem is with the invoice issue datetime and product bill-to datetime, while they have the same mm/dd/yyyy they have different times. I tried converting those fields to just mm/dd/yyyy so that I could use a formula on the product such as: if the billtodate.producttable is greater than the issuedate.invoicetable then N else Y to then filter out the N's. But that is not working.
IP IP Logged
CindyS
Newbie
Newbie
Avatar

Joined: 29 May 2013
Location: United States
Online Status: Offline
Posts: 7
Quote CindyS Replybullet Posted: 03 Dec 2014 at 10:42am
Whoot hoot, I figured it out! It must have been something with the way I had it edited, the formula to use the converted fields. I deleted them, redid them and then now I have my Y and N so I can remove the N's. Thanks so much for your help!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum