Trigger to format date

Asked

Viewed 85 times

1

create trigger tr_Fmt_Data before insert
on Tempos
for each row
set new.Mes = date_format(new.Datas, "%M");

insert into Tempos (Datas) values("2017-10-03");

Would it be possible for you to help me complete Rigger from above? I intend to format the date entered in the Dates field, assuming the Month field only the Date month.

  • I don’t understand, you can explain to me better what you want?

  • Well, I intend to enter the date 2017-10-03 in the Dates field and have Trigger tr_Fmt_Data write in the Month field "October".

  • Please enter the date table creation structure, so you can write the entire Trigger.

  • Why is this field "written" ? The value is redundant and can be obtained by sql or virtual column.

  • Solved, the problem was the formatting of the Mes field, assign it to varchar create Trigger tr_test before Insert on Services for each Row set new. Mes = date_format(new.Dates,"%M");

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.