R
Rizwan
Hi All,
My task is to retrieve 2 dates from a table; manipulate them based on some
rules and then use them in a SELECT statement to get data from another
table. That SELECT statement is "SELECT sum(hours) FROM time_sheet WHERE
date_worked between :startDate and :endDate".
First I got those 2 dates from a table and store them in 2 java.util.Date
variables:
ResultSet rs = null;
....
java.util.Date startDate = rs.getDate("start_date");
java.util.Date endDate = rs.getDate("start_date");
....
When I print these variables they print in yyyy-MM-dd format:
startDate= 2005-01-17
endDate= 2005-01-30
Now i add 6 days in the endDate
Calendar aCalendar = Calendar.getInstance();
aCalendar.setTime( endDate );
aCalendar.add( Calendar.DATE, 6 ); // add days to the Calendar
endDate = aCalendar.getTime(); // convert from Calendar to
date
Now when I print endDate variable, it prints in different format:
endDate = Sun Jan 23 00:00:00 EST 2005
My question is why it is now printing in this format? I now cannot use them
in my SELECT statement becuase of this format. Can anybody help me please?
Thanks
Rizwan
My task is to retrieve 2 dates from a table; manipulate them based on some
rules and then use them in a SELECT statement to get data from another
table. That SELECT statement is "SELECT sum(hours) FROM time_sheet WHERE
date_worked between :startDate and :endDate".
First I got those 2 dates from a table and store them in 2 java.util.Date
variables:
ResultSet rs = null;
....
java.util.Date startDate = rs.getDate("start_date");
java.util.Date endDate = rs.getDate("start_date");
....
When I print these variables they print in yyyy-MM-dd format:
startDate= 2005-01-17
endDate= 2005-01-30
Now i add 6 days in the endDate
Calendar aCalendar = Calendar.getInstance();
aCalendar.setTime( endDate );
aCalendar.add( Calendar.DATE, 6 ); // add days to the Calendar
endDate = aCalendar.getTime(); // convert from Calendar to
date
Now when I print endDate variable, it prints in different format:
endDate = Sun Jan 23 00:00:00 EST 2005
My question is why it is now printing in this format? I now cannot use them
in my SELECT statement becuase of this format. Can anybody help me please?
Thanks
Rizwan