0

I have a date column in oracle. When I'm trying to save data from Spring Boot, it always appends time along with the date. Is there any way I can restrict the time (From Oracle) and only save date in that column without having to do it from Spring Boot. Any help will be very grateful

Current data stored: 11/18/2020 5:00:00 AM
Required Format    : 11/18/2020
Littlefoot
  • 78,293
  • 10
  • 26
  • 46
Mirza Bilal
  • 403
  • 3
  • 13

1 Answers1

1

I don't know Spring Boot, but - see if you can save truncated value, e.g.

insert into your_table (date_column) values (TRUNC(sysdate));
                                             -----
                                             this

If not, create a BEFORE INSERT trigger on that table which will truncate the time part, e.g.

create or replace trigger trg_bi_yourt
  before insert on your_table
  for each row
begin
  :new.date_column := trunc(:new.date_column);
end;
/
Littlefoot
  • 78,293
  • 10
  • 26
  • 46