Reputation: 31
How can I add a date of birth into a table? I'm not sure how to properly format using the TO_CHAR function. Currently have
INSERT INTO Participant (PartDOB,)
VALUES (TO_CHAR(sysdate, 'DD-MM-YYYY')'18-09-1964')
But it just returns with "missing comma". What's the correct way to format it?
Upvotes: 0
Views: 12920
Reputation: 1270391
In most databases, just use ISO standard date formats:
INSERT INTO Participant (PartDOB, . . .)
VALUES ('1964-09-18', . . .)
In Oracle (suggested by TO_CHAR()
and sysdate
), you need to precede this with DATE
to indicate a date constant:
INSERT INTO Participant (PartDOB, . . .)
VALUES (DATE '1964-09-18', . . .)
You would use sysdate
just to get the current date/time.
Upvotes: 1