Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a specific date in HSQLDB?

I need to create a HIGH date in HSQLDB and the solution is eluding me. I need something like

Date(9999-12-31 0:0:0)

but I cannot find a function or whatever to do it. I am loding the date via Spring on startup and i need something like:

insert intoMOD (
  ITM_INST_ELECTR_MOD_STRT_TS,
  ITM_INST_ID,
  ELECTR_MOD_ID,
  ITM_INST_ELECTR_MOD_END_TS
) VALUES (
  CURRENT_DATE,
  0,
  0,
  Date(9999-12-31 0:0:0)
)

What is the way to create a specific data using SQL in Hypersonic?

like image 541
markthegrea Avatar asked Oct 30 '12 14:10

markthegrea


2 Answers

I was struggling with this problem and I think that I can contribute to help some other people.

Here is the insert that you need to put on your script while loading hsqldb:

insert intoMOD (
  ITM_INST_ELECTR_MOD_STRT_TS,
  ITM_INST_ID,
  ELECTR_MOD_ID,
  ITM_INST_ELECTR_MOD_END_TS
) VALUES (
  CURRENT_DATE,
  0,
  0,
  '9999-12-31'
)

HSQLDB converts the string automatically.

I tested with latest version (2.3.3).

like image 187
Thiago Santana Avatar answered Oct 23 '22 20:10

Thiago Santana


Given the user guide, I'd expect the following to work:

DATE '9999-12-31'

or, if you need more than day precision:

TIMESTAMP '9999-12-31 00:00:00'
like image 37
Jon Skeet Avatar answered Oct 23 '22 20:10

Jon Skeet