Menu

#1737 Can't retrieve temporals in BC era

version 2.5.x
open-later
None
5
2025-08-12
2025-08-07
No

The methods in org.hsqldb.types.HsqlDateTime all fail to account for the ERA when operating on calendars, which prevents reading correct data. If the database has a temporal in the BC era, it always comes out in CE era instead.

In convertMillisFromCalendar and convertSecondsFromCalendar the target calendar also needs to copy over the era like so: targetCalendar.set(Calendar.ERA, sourceCalendar.get(Calendar.ERA));

Similarly in convertMillisToCalendar the like so: calendar.set(Calendar.ERA, tempCalGMT.get(Calendar.ERA));

resetToDate and resetToTime should probably also do cal.set(Calendar.ERA, GregorianCalendar.CE);

Discussion

  • Fred Toussi

    Fred Toussi - 2025-08-12
    • status: open --> open-later
    • assigned_to: Fred Toussi
     
  • Fred Toussi

    Fred Toussi - 2025-08-12

    Hi Christian,

    For dates (and timestamps) I followed the SQL Standard which allows 0001 to 9999 for the year and does not allow BCE values. This is enforced in date-time literals which do not allow BCE values. When using assignments via Java PreparedStatement etc. and arithmetics involving INTERVAL there is no range checking.

     
  • Christian Beikov

    One can produce BC timestamps with to_timestamp('BC 0001-01-01 00:00:00', 'BC YYYY-MM-DD HH:MI:SS').

     
  • Fred Toussi

    Fred Toussi - 2025-08-12

    For future reference, it's good to know where there are no checks. Still, literals such as DATE 'BC 0001-01-01 00:00:00' are not allowed

     

Log in to post a comment.

MongoDB Logo MongoDB