Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting Date from Database table:  In JAVA

Posted on 2006-07-17
1
Medium Priority
?
275 Views
Last Modified: 2010-05-18
Hello All,

I want to get Date from a DB2 table which is declared as Timestamp.  I want to have date printed in a jsp page in the format Month, Year.
can you please inform me, how can i do this ?
do i have to declare it as Date format or string format and get from the result set?

thanks
0
Comment
Question by:altima4u
1 Comment
 
LVL 3

Accepted Solution

by:
x_bakos earned 200 total points
ID: 17125128
Hi,

the way I do it is the followng in JAVA:

String query = "select to_char(ta.date,'DD/MM/YYYY') as the_date "+
                  "from [table] ta "+
                  "where [where_clause]";

Notice that "ta.date" means that you take the column "date" from [table]....

Try to make the above work for your tables....

Hope to have helped

Bakos
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

926 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