File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting a Four Digit Date from SQL call

 
Steve Dyke
Ranch Hand
Posts: 1602
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1602
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic