Subject | How to retrieve a value from a Date field of a ResultSet |
---|---|
Author | dobedani |
Post date | 2006-05-23T16:48:35Z |
Dear All,
I have a SQL query - stored in a variable sqlStr - as follows:
SELECT SUBSTR(FVALUE, 18, 100),
CAST(SUBSTR(FVALUE, 5, 14) AS DATE) AS FDate
FROM TSETTINGS
WHERE etc.
I tried this query in IBConsole - the underlying database is
Firebird ;-) Today's date was shown as: 23/05/2006, i.e. that works
fine!
Then I passed this query to method executeQuery of a Statement:
Statement stmt = fbconn.createStatement();
ResultSet rset = stmt.executeQuery(sqlStr
If any records are returned, I would of course like to retrieve the
date and eventually to represent this date as a String - e.g.:
Date d = rset.getDate(2);
out.println(d.getDay() + "-" + (d.getMonth() + 1) + "-" + d.getYear());
The result is not what one would expect. Today's date comes out as
0106-05-02! Yes, the methods getDay, getMonth and getYear are
deprecated, I know! And I know how to work with the Calendar class,
but how to do so in this context? Any help would be appreciated.
Kind regrds,
Dobedani
I have a SQL query - stored in a variable sqlStr - as follows:
SELECT SUBSTR(FVALUE, 18, 100),
CAST(SUBSTR(FVALUE, 5, 14) AS DATE) AS FDate
FROM TSETTINGS
WHERE etc.
I tried this query in IBConsole - the underlying database is
Firebird ;-) Today's date was shown as: 23/05/2006, i.e. that works
fine!
Then I passed this query to method executeQuery of a Statement:
Statement stmt = fbconn.createStatement();
ResultSet rset = stmt.executeQuery(sqlStr
If any records are returned, I would of course like to retrieve the
date and eventually to represent this date as a String - e.g.:
Date d = rset.getDate(2);
out.println(d.getDay() + "-" + (d.getMonth() + 1) + "-" + d.getYear());
The result is not what one would expect. Today's date comes out as
0106-05-02! Yes, the methods getDay, getMonth and getYear are
deprecated, I know! And I know how to work with the Calendar class,
but how to do so in this context? Any help would be appreciated.
Kind regrds,
Dobedani