I need to get the number of days in a month from the Register table. Im using the following SQL Query :
SELECT DateTo::Date-DateFrom::Date AS DaysInMonth FROM Register;
While executing it in SQL Editor of PostgreSQL Im getting the following result :

While executing the same through java code Im getting the result as 29 days instead of 29
Im adding the java code here
sql = " SELECT DateTo::Date-DateFrom::Date AS DaysInMonth FROM Register; "
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, payReg.getC_Period_ID());
rs = pstmt.executeQuery();
while (rs.next()){
System.out.println(rs.getString("DaysInMonth"));
}
}catch (SQLException e){
e.printStackTrace();
}
What may be the reason..?
I need to get just 29 from the java execution. How do I get it..?
Thanks in advance.
get the number of days in a month...