[英]Convert the Date Format
Using SQL Server 2005 使用SQL Server 2005
Table1 表格1
ID Date
001 01/12/2010
002 15/12/2010
....
DateFormat: dd/mm/yyyy 日期格式:dd / mm / yyyy
I want to change the dateformat like mm/dd/yy by using select query 我想通过使用选择查询来更改日期格式,例如mm / dd / yy
Select id, date from table1
Expected Output 预期产量
ID Date
001 12/01/2010
002 12/15/2010
....
How to make a query for the above format. 如何查询以上格式。
Need Query Help. 需要查询帮助。
You can use convert
to specify a mm/dd format, like 101: 您可以使用
convert
指定mm / dd格式,例如101:
select CONVERT(varchar(30), YourColumn, 101)
If your table stores dates as a string, you'd have to convert the string to a date first, like: 如果表将日期存储为字符串,则必须首先将字符串转换为日期,例如:
select CONVERT(varchar(30), CONVERT(datetime, YourColumn), 101)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.