Solved

Formula to create coupon on POS receipt

Posted on 2012-12-31
5
338 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 22

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 28

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 100

Accepted Solution

by:
mlmcc earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

832 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