0

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?

discord1
  • 31
  • 1
  • 3
  • 8

1 Answers1

1

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786