| Author |
dates and times as integers in a query string
|
Kirk Martin
Greenhorn
Joined: Nov 29, 2004
Posts: 4
|
|
I'm trying to insert dates and times into a database. The dates are displayed from the database as for example March 1, 2005 - but in the database the id is 1 April 1, 2005 - and for April the id is 2 I want the users to see March 1, 2005 which I do now but need to pass 1 to the query string and 2 etc. How can I change the dates in the background using JSP to the Integer of 1 for March and 2 for April or for that matter whatever date the user clicks on? My servlet needs to see the dates and times as an integer or it wont work. Any help would be appreciated. [ December 04, 2004: Message edited by: Kirk Martin ]
|
 |
Logan Owen
Greenhorn
Joined: Dec 01, 2004
Posts: 24
|
|
I am not completely clear on what you are wanting, but my suggestion would to use a if else statement (actually, a switch statement, but I don't remember the exact syntax). Pull out the month, and try something like this: so on and so forth. Also, it is best to put logic code in a class outside of the JSP and call it from the JSP. And always remember to include a default case, just in case something breaks down, the whole application will not fail.
|
 |
Kirk Martin
Greenhorn
Joined: Nov 29, 2004
Posts: 4
|
|
What i'm wanting is to pass 1 or 2 or 3 or 4 etc. (these are the dateID numbers in the database) depending on what date the user clicks on in the form. So for example if you (Logan Owen) clicks on April 1, 2005 in the query string it will be number 2 instead of April, 1 2005. The reason is because in my servlet (I'm using switch and a case to do the processing) I have for the dates - ds.setDateID(Integer.parseInt(request.getParameter("dateID"))); If you have any questions or a solution let me know. Thanks Kirk
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26173
|
|
Kirk, You can set the value in your JSP. For example,
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26173
|
|
|
Moving to our JSP forum as this is more about JSP than JDBC.
|
 |
 |
|
|
subject: dates and times as integers in a query string
|
|
|