Solved

Getting Date from Database table:  In JAVA

Posted on 2006-07-17
1
265 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

827 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