?
Solved

operation on date

Posted on 2003-02-22
5
Medium Priority
?
272 Views
Last Modified: 2008-02-26
hello!experts...
    my problem is this...
    i have a store and i accept new members...once the membership is approved i would store the date when a particular member have been approved.. then after that i would have to keep track if the member is already in its one year so that i could give the member some discounts....how would i do it in java 1.3?
     please do help me...
     thank you...

0
Comment
Question by:lovelykim
[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
 

Author Comment

by:lovelykim
ID: 7998304
i would really be glad to have your answers...thanks...
0
 
LVL 1

Accepted Solution

by:
umangjoshi earned 200 total points
ID: 7998554
u can use sql query to solve ur problem..

[1] in case of oracle

select date1 - date2 as days from ....

the above returns the difference between two dates in no of days...

[2] the same thing using mysql

select to_days(date1) - to_days(date2) as days from ...

0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 200 total points
ID: 7999288
1. use java.util.Date or it's subclass java.sql.Date to store/retrieve member join date to file or DB, e.g.
ResutSet rs = .....
Date joinDate = rs.getDate("joinDate");

PreparedStatement ps = .....
ps.setDate( 1, joinDate );

2. use java.text.SimpleDateFormat to convert between String and Date object, for example:
SimpleDateFormat df = new SimpleDateFormat( "MM/dd/yyyy" );
Date myDate = df.parse( "02/20/2003" );
String strDate = df.format( myDate );

3. use java.util.Calendar to track a year back:
Calendar cal = Calendar.getInstance();
cal.add( Calendar.YEAR, -1 ); //go back one year;
Date aYearBack = cal.getTime();

3. to compare date:
if( joinDate.before( aYearBack ) ) {
   // get discount
} else {
   // no discount
}
0
 
LVL 35

Expert Comment

by:girionis
ID: 9990263
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between umangjoshi and kennethxu

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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