• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting a Four Digit Date from SQL call

 
Steve Dyke
Ranch Hand
Posts: 1722
1
  • 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
Posts: 21991
36
Eclipse IDE Firefox Browser MySQL Database
  • 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: 1722
1
  • 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
Posts: 20837
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!