?
Solved

Formula to create coupon on POS receipt

Posted on 2012-12-31
5
Medium Priority
?
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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 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

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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