I have a table in sql as follows:
CREATE TABLE Reserves(
sid INTEGER,
bid INTEGER,
day DATE,
PRIMARY KEY (sid, bid, day),
FOREIGN KEY (sid) REFERENCES Sailors,
FOREIGN KEY (bid) REFERENCES Boats
);
and I’m trying to insert into it:
INSERT INTO Reserves VALUES(22, 101, '01-01-1998');
But I get the error: ORA-01843: not a valid month
This is an Oracle db. I’m not sure what’s wrong with my date format.
It’s not entirely clear which you wanted, so you could try:
For month-day-year format:
INSERT INTO Reserves VALUES(22, 101, TO_DATE('01-01-1998','MM-DD-YYYY'));For day-month-year format:
INSERT INTO Reserves VALUES(22, 101, TO_DATE('01-01-1998','DD-MM-YYYY'));Also, recommended reading: Oracle functions: TO_DATE