| | |
checking to see if a coupon has expired
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2004
Posts: 7
Reputation:
Solved Threads: 0
Hello,
I am trying to set up my website to be able to accept coupons. I am working in JSP and want to be able to get the current date and compare it to the date stored in the database. I have a field in the coupon table named 'Expiry' which is of type 'date'.
So far I have been able to retrieve the date from the database
and have printed it successfully
I am trying to do the following:
I have tried setting 'today' up as a Date object:
but it says that it cannot resolve symbol and points at 'new'
I have also tried setting 'today' up as a Calendar object, but can not figure out how to make that work either.
Any help would be most appreciated as the company is planning on handing out coupons in just over a week!
Thanks in advance,
Dave.
I am trying to set up my website to be able to accept coupons. I am working in JSP and want to be able to get the current date and compare it to the date stored in the database. I have a field in the coupon table named 'Expiry' which is of type 'date'.
So far I have been able to retrieve the date from the database
JSP Syntax (Toggle Plain Text)
... out.print(rs.getDate("Expiry")); }
I am trying to do the following:
JSP Syntax (Toggle Plain Text)
if(rs.getDate("Expiry") != null && rs.getDate("Expiry") < today){<blockquote>set coupon to invalid</blockquote>}
I have tried setting 'today' up as a Date object:
JSP Syntax (Toggle Plain Text)
<%@page language="java" import="java.sql.Date"%> ... Date today = new Date();
I have also tried setting 'today' up as a Calendar object, but can not figure out how to make that work either.
Any help would be most appreciated as the company is planning on handing out coupons in just over a week!
Thanks in advance,
Dave.
•
•
Join Date: Mar 2004
Posts: 7
Reputation:
Solved Threads: 0
Hey, I found the solution - turns out to be all mySQL... in case anyone is interested, here it is:
Dave.
JSP Syntax (Toggle Plain Text)
ResultSet rs = statement.executeQuery("select * from Coupons where Name='"+ coupon.getName() +"' and Expiry>=CURDATE()"); if(rs.isBeforeFirst() == rs.isAfterLast()){ coupon.setErrorFree(false); rs = statement.executeQuery("select * from Coupons where Name='"+ coupon.getName() +"' and Expiry<CURDATE()"); ... set coupon to invalid ... }
Dave.
![]() |
Similar Threads
- Outlook 2007: expired digital certificates (Windows Software)
- youngest person to pass the SCJA certification? (Java)
- Timing Execution (C++)
- Windows 2000 Password Expired (Windows NT / 2000 / XP)
- Writing a coupon on HTML language (HTML and CSS)
- How to Perform Disk Error Checking in Windows XP (Windows tips 'n' tweaks)
Other Threads in the JSP Forum
- Previous Thread: connecting to mssql with using jsp
- Next Thread: Error: illegal target of jump or branch
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write





