格式日期为DD-MM-YYYY [英] date of format to be DD-MM-YYYY

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

问题描述

我创建了一个数据库如下;



出生日期时间(数据类型)



在数据库商店中作为1/9/1986 12:00:00



但我希望格式为1-sep-1986。





怎么办。当我的数据类型为的列时,请帮助我。

解决方案

...



1#



在开放模式下表记录视图,(表格名称 - >右键单击 - >打开
显示日期格式的
取决于系统日期格式

注意:用于测试更改系统日期格式并关闭&重新打开sql server并再次打开表





2#



但请记住,

什么时候

插入日期

更新日期

比较日期在哪里条件与日期栏

使用格式''yyyy-MM-dd''





3#



你可以只以你想要的格式显示日期,它不会影响表数据

获取不同格式的显示日期数据使用sql查询选择语句,默认显示日期为''yyyy-MM-dd''

在select语句中你可以 选择格式 使用sql函数,

示例

 选择 getdate() [默认] 
选择 转换 varchar 10 ),getdate(), 103 as [dd-MM-yyyy]
选择 转换 varchar (< span class =code-digit> 10 ),getdate(), 101 as [MM-dd-yyyy]
选择 转换 varchar 10 ),getdate(), 102 as [yyyy-MM-dd]



更多日期格式...

http://www.sql-server-helper.com/tips/date-formats。 aspx

http://msdn.microsoft.com/en-us/library/ms189491.aspx [ ^ ]



所以,回答你的问题是你无法存储以您希望的格式显示日期< br /> 
但您可以以不同的格式显示它





快乐编码!

:)


在DataBase中,它应该保存在1/9/1986 12:00:00中。这种格式只有。

你不能把它存放在1-sep-1986中。这种格式。

但是在前端你可以显示你想要的类型。没有机会存储在Backend


嗨亲爱的,



在后端,按照运行数据库的pc日期格式存储的格式。



您可以将其作为您的来自数据库的格式,如---

 选择替换(转换 Nvarchar ,getdate(), 106 ),' ''   - 


i have created a database as follows;

Date of birth datetime(datatype)

in data base store as 1/9/1986 12:00:00

but i want the format 1-sep-1986.


how to do.pleae help me.

解决方案

when a column having datatype date...

1 #

In Open mode Table Records view,(table name -> right clicked -> open)
displaying date''s format is depends on System Date format.
Note: for testing change system date format and close & reopen sql server and open table again


2 #

but remember always,
when ever
inserting date
updating date
or comparing date in where condition with date column
use format ''yyyy-MM-dd''


3 #

you can Just display date in format you want, it does not effect table data
for display date in different formats while fetching data using sql query select statement, by default display date is ''yyyy-MM-dd''
in select statement you can choose format using sql functions,
example

select getdate() as [default]
select convert(varchar(10),getdate(),103) as [dd-MM-yyyy]
select convert(varchar(10),getdate(),101) as [MM-dd-yyyy]
select convert(varchar(10),getdate(),102) as [yyyy-MM-dd]


for more date formats...
http://www.sql-server-helper.com/tips/date-formats.aspx
http://msdn.microsoft.com/en-us/library/ms189491.aspx[^]

so, answer of your question is you can not store date in a format you desire<br />
but you can display it in different format



Happy Coding!
:)


In DataBase it should be saved in "1/9/1986 12:00:00" this format only.
You can''t store it in "1-sep-1986" this format.
But in Front End you can display what type you want.There is no chance to store in Backend


hi dear,

In Backend, the format stored as per pc Date Format on which database is running.

You Can fatch it as your format from database like---

select Replace(convert(Nvarchar,getdate(),106),' ','-')


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

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