This is the table that I have. Effective date is a user input, then I need to use a trigger that produces Print depending on the language the user inputs (English or French only).
For English, I used DATE_FORMAT to achieve the output as shown, but I am completely lost on what I should do if the user chooses French. The desired output would be 23 Mai 2016.
I was thinking of storing all the months in a separate table and then calling that table depending on the month component of the date provided but I'm still not sure if that will work. Any help is appreciated.
╔══════════╤════════════════╤═════════════╗
║ Language │ Effective Date │ Print ║
╠══════════╪════════════════╪═════════════╣
║ English │ 23/05/2016 │ 23 May 2016 ║
╟──────────┼────────────────┼─────────────╢
║ French │ 23/05/2016 │ ║
╚══════════╧════════════════╧═════════════╝
Edit:
Trigger Code:
DELIMITER |
CREATE TRIGGER printdate
BEFORE INSERT ON `h&a` FOR EACH ROW
BEGIN
IF NEW.language = "English"
THEN
SET NEW.print = DATE_FORMAT(NEW.`effective date`, '%d %M %Y')
END IF;
END|
DELIMITER ;
Best Answer
Here is a way to get the name of the month in French, then you can use CONCAT to construct the date however you want:
Working example: