从此格式更改日期“MM / DD / YY”到“MM / DD / YYYY” [英] Changing dates from this format "MM/DD/YY" to "MM/DD/YYYY"

查看:131
本文介绍了从此格式更改日期“MM / DD / YY”到“MM / DD / YYYY”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程很新。我在表格中有一列,其出生日期格式如下 - MM / DD / YY。我在该表上运行了以下select语句



select * from TABLE.NAME其中ID ='999999999'和birthdate = '13 -JAN-46';





由于年份为2位数,很难说'46'是1946还是2046





我想弄清楚是否有一种方法可以从该表中选择并按以下格式生日:MM / DD / YYYY





任何帮助将不胜感激。



谢谢,

Mayo

I am fairly new into programming. I have a column in a table that has the birth-date in the following format --"MM/DD/YY". I ran the following select statement on that table

select * from TABLE.NAME where ID = '999999999' and birthdate = '13-JAN-46';


Because of the year being 2 digit it would be hard to tell if the '46' is 1946 or 2046


I am trying to figure out if there is a way I could select from that table and have the birthdate in the following format: "MM/DD/YYYY"


Any help will be appreciated.

Thanks,
Mayo

推荐答案

假设日期存储为日期字段,那么您可以使用
以您想要的格式显示日期


选择转换(varchar(10),[BirthDate],101)作为BirthDate FROM ....



101是MM / DD / YYYY的日期代码



参考 http://msdn.microsoft.com/en-nz/ library / ms187928.aspx [ ^ ]用于所有日期代码。
Assuming the date is stored as a date field then you can display it in the format you want by using

select Convert(varchar(10),[BirthDate],101 ) as BirthDate FROM ....

101 is the Date Codes for MM/DD/YYYY

Refer to http://msdn.microsoft.com/en-nz/library/ms187928.aspx[^] for all date codes.


这篇关于从此格式更改日期“MM / DD / YY”到“MM / DD / YYYY”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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