将数据表中的列的日期时间格式设置为"dd/MM/yyyy"; [英] seting datetime format for a column in a datatable as "dd/MM/yyyy"

查看:134
本文介绍了将数据表中的列的日期时间格式设置为"dd/MM/yyyy";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个数据表,其中包含一列数据类型为datetime的列.当我执行查询以填充sql server中的表时,我以dd/MM/yyyy格式获取日期.当我使用相同的查询填充表格时,它将以MM/dd/yyyy格式填充列.我想在数据表中将日期格式设置为dd/MM/yyyy.我怎样才能做到这一点.
谢谢..

Hi I have a data table that contains a column with datatype datetime. When i execute the query to fill the table in sql server i get the dates in dd/MM/yyyy format. When i fill the table using the same query it fills the column in MM/dd/yyyy format. I want to have the date format as dd/MM/yyyy in the datatable. How can i get it possible.
Thanks..

推荐答案

可以有两种方法-
1)在数据库级别处理转换.您可以使用Convert 方法 [ http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [
There could be two ways to do this -
1) Handle the conversion at the database level. You can use the Convert method [^]to this in your query.
2) Handle it once data comes back to the form. If you want to handle this in your code, you can convert the datetime in the source of the datatable, using toString() (http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^])


这篇关于将数据表中的列的日期时间格式设置为"dd/MM/yyyy";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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