[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Formula to create coupon on POS receipt

Posted on 2012-12-31
5
Medium Priority
?
350 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

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 part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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