Solved

Formula to create coupon on POS receipt

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…

732 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