User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 401,673 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 3,472 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: 3485 | Replies: 1
Reply
Join Date: Mar 2004
Posts: 7
Reputation: Dave G. is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Dave G. Dave G. is offline Offline
Newbie Poster

checking to see if a coupon has expired

  #1  
Oct 14th, 2004
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
...
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();
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Posts: 7
Reputation: Dave G. is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Dave G. Dave G. is offline Offline
Newbie Poster

Re: checking to see if a coupon has expired

  #2  
Oct 14th, 2004
Hey, I found the solution - turns out to be all mySQL... in case anyone is interested, here it is:

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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 7:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC