?
Solved

Formula to create coupon on POS receipt

Posted on 2012-12-31
5
Medium Priority
?
352 Views
Last Modified: 2013-01-16
I have a pervasive database where the dates are stored in string like this 20101215

Dec 15 2012 = 20101215 which is my invoice date

I want to create a formula in crystal that will do this

If invoice date is between X and Y, then expiration date is Z

Z value is a hard coded date.

The formula is to create coupon on POS receipt
0
Comment
Question by:Gerhardpet
5 Comments
 
LVL 23

Expert Comment

by:Ido Millet
ID: 38732667
stringvar ls_date := "20101215";
cDate(cdbl(ls_date[1 to 4]), cdbl(ls_date[5to 6]), cdbl(ls_date[7 to 8]));
0
 
LVL 29

Expert Comment

by:Bill Bach
ID: 38732674
That's not really "good" logic.  What will you do if the date is outside of that period?

My suggestion would be to use logic in your SELECT statement to bring in the expiration date along with the regular date.  Assuming that ExpiryDate is NULL if not within that range, then this should work:

SELECT InvoiceDate, IF(ExpiryDate >= X and ExpiryDate <= Y,Z,NULL) FROM ReceiptTable
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38732701
Something like this... ( assume x and y are parameter fields; I have called them startdate and enddate)

Datevar dtdt;
dtdt:=cdate(Picture(totext({table.invoicedate},0,""), "xxxx/xx/xx"));
if dtdt in [{?startdate} to {?EndDate}] then
"30 June 2012"
else
""
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 38735321
@BillBach
You see I have not expiration date as a database field. I need to make up the expiration date based on the invoice date.

So I will have 4 expiration dates in one year (end of spring, summer, fall and winter).

If the invoice date is June the 1st 2013 (which is between March the 20th and June the 20th 2013) then the expiration date will be June the 20th 2013 (which is the last day of spring)

All I have is the invoice date as a database field. Does that make sense?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 38735343
Something like

If {InvoiceDateField} <= Date(Year(InvoiceDateField),3,19) then
     Date(Year(InvoiceDateField),3,19)
Else if If {InvoiceDateField} <= Date(Year(InvoiceDateField),6,20) then
    Date(Year(InvoiceDateField),6,20)
Else if {InvoiceDateField} <= Date(Year(InvoiceDateField),9,20) then
    Date(Year(InvoiceDateField),9,20)
Else if {InvoiceDateField} <= Date(Year(InvoiceDateField),12,20) then
    Date(Year(InvoiceDateField),12,20)
Else
    Date(Year(InvoiceDateField)+1,3,19)


mlmcc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

807 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