•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 375,207 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,318 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 3405 | Replies: 1
![]() |
•
•
Join Date: Mar 2004
Posts: 7
Reputation:
Rep Power: 0
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
...
out.print(rs.getDate("Expiry"));
}and have printed it successfully
I am trying to do the following:
if(rs.getDate("Expiry") != null && rs.getDate("Expiry") < today){set coupon to invalid
}I have tried setting 'today' up as a Date object:
<%@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:
Rep Power: 0
Solved Threads: 0
Hey, I found the solution - turns out to be all mySQL... in case anyone is interested, here it is:
Dave.
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
Similar Threads
- Windows 2000 Password Expired (Windows NT / 2000 / XP / 2003)
- Beginner needs assistance with 'error checking' program (C++)
- Checking file on System C (Windows NT / 2000 / XP / 2003)
- 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


Linear Mode