[英]how do I add a leading zero to a column?
So I am importing a customer table and the date values are missing the leading zero for the month, so month column has a value of 2 instead of 02. How can I add a leading zero to the effected dates without adding a zero to dates where the leading zero is no issue? 因此,我正在导入一个客户表,并且日期值缺少该月的前导零,因此month列的值是2而不是02。如何在不影响日期的情况下将前导零添加到生效日期,而在其中前导零没有问题吗? Any help is appreciated.
任何帮助表示赞赏。 Thanks
谢谢
If you're storing dates, you should be storing them into a date column in MySQL. 如果要存储日期,则应将其存储到MySQL中的date列中。 It'll pad appropriately, and you'll be able to do proper date-based queries on the data like
WHERE BETWEEN
or using MySQL's INTERVAL
math. 它将适当地填充,并且您将能够对数据进行适当的基于日期的查询,例如
WHERE BETWEEN
或使用MySQL的INTERVAL
数学。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.