在存储过程中组合日期格式和字符串 [英] Combine Date formatted and String in Stored Procedure
本文介绍了在存储过程中组合日期格式和字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这里有一个示例代码..
I have a sample code here..
DECLARE d_progcode VARCHAR(6);
DECLARE d_header VARCHAR(30);
DECLARE d_body LONGTEXT;
DECLARE d_date VARCHAR(50);
SET d_progcode = "SAMPLE";
SET d_header = "Sample Confirmation";
SET d_body = "String 1" + DATE_FORMAT(NOW(), '%D of %M, Year %Y') + ". String 2";
INSERT INTO sample_email (`prog_code`,`sto`,`ssubject`,`sbody`,`datecreated`) VALUES (d_progcode,sto_email,d_header,d_body,NOW());
我正在尝试组合格式化的字符串和日期,但是当我将其插入表中时出现错误
I am trying to combine string and date formatted but when I insert it in table there is an error
截断不正确的 DOUBLE 值
推荐答案
在 mysql 中如果要连接字符串值需要使用 concat
In mysql if you want to concatenate string values you need to use concat
SET d_body = concat("String 1" , DATE_FORMAT(NOW(), '%D of %M, Year %Y') , ". String 2");
这篇关于在存储过程中组合日期格式和字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文