Solved

Getting Date from Database table:  In JAVA

Posted on 2006-07-17
1
268 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
[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
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Progress
Starting up a Project

628 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