Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting a Four Digit Date from SQL call

 
Steve Dyke
Ranch Hand
Posts: 1679
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: 21416
33
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: 1679
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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic