File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Getting a Four Digit Date from SQL call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Getting a Four Digit Date from SQL call" Watch "Getting a Four Digit Date from SQL call" New topic
Author

Getting a Four Digit Date from SQL call

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
I am getting remote data from a db2 data source. Eventhough the date field I am getting my data from has a four digit year my SQL result only has two digit year. Please help. When ever I try and change the format of the date to a four digit after it is returned I get a year like 0009

My connection is using:
import com.ibm.as400.access.AS400JDBCDataSource;

My SQL:
String sqlmin = "Select MIN(ftdatem) As minDate From " + this.ls + ".resmngt3 Where projindex = " + arg0;
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

What type is the column "ftdatem"? Date? Numeric? String?

Also, I don't see any code there which claims to change the format of a date, so it's hard to say much about that.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
The datatype is Date.

After more looking I found that this will do the trick. Thanks for the reply.

String sqlmin = "Select CHAR(MIN(ftdatem),USA) As minDate From " + this.ls + ".resmngt3 Where projindex = " + arg0;
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Moving to the JDBC forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting a Four Digit Date from SQL call