在Mysql中将DateTime值转换为String [英] Convert DateTime Value into String in Mysql

查看:353
本文介绍了在Mysql中将DateTime值转换为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换日期&时间值到varchar然后存储在数据库中

I want to convert Date & time value into varchar and then store in database

我正在获取当前日期&时间在mysql中使用NOW(),现在想在字符串中转换,因为我必须将此值与字符串值合并

I am fetching the Current Date & time using NOW() in mysql and now want to convert it in string because i have to merge this value with String value

推荐答案

使用 DATE_FORMAT()

SELECT
  DATE_FORMAT(NOW(), '%d %m %Y') AS your_date;

这篇关于在Mysql中将DateTime值转换为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆