Reputation: 25
im trying to make an SQL table with custom date format
CREATE TABLE Basketbal.Bestuurslid (
`lidnummer` INT NOT NULL,
`begin_datum` DATE NOT NULL,
`eind_datum` DATE NULL,
`functie` VARCHAR(45) NULL,
PRIMARY KEY (`lidnummer`, `begin_datum`));
(I know it's in dutch)
im trying to make begin_datum
& eind_datum
in the following format:
1-jan-07 ('%e-%b-%y')
but I cant get it to work
any suggestions?
Upvotes: 1
Views: 3107
Reputation: 25
Thank you for your awnsers. i solved it by not using the format DATE and just using VARCHAR();
kind regards,
Chiel
Upvotes: 0
Reputation: 16
Once you have your data stored in your table you could pull your data in the format you want it, example:
CONVERT(VARCHAR(11),begin_datum,6)
Upvotes: 0
Reputation: 1269753
date
is an internal format in the database. You can convert it to (or from) a string using date_format()
(and str_to_date()
). That controls the character representation of the value, not the value itself. So, when you select from the table:
select date_format(begin_datum, '%e-%b-%y')
If you really feel strongly about not explicitly calling this function, you can put the date logic into a view and access the table through the view.
Upvotes: 1