仅插入日期时间格式的日期 [英] inserting only date for a datetime format

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

问题描述

你好



我正在使用一个列的日期时间数据类型并在其中插入一个文本框的值,我想只插入日期但在表格中时间也插入日期



我怎么能只插入日期

hello

I am using datetime data type for a column and insert the value of a text box in it and i want to insert only date but in the table time also inserted with date

how can i insert only date

推荐答案

Convert.ToDateTime(textbox。文本)。日期
Convert.ToDateTime(textbox.text).Date


尝试一些像..... /。

try some thing like ...../.
Convert.ToDateTime(Textbox1.Text).Date;


如果您不需要日期字段的时间,为什么不将列数据类型更改为DATE?

然后你可以使用

if you don''t need the time of the date field why don''t you change the column data type as DATE?
then you can insert date in to column by using
Convert.ToDateTime(Textbox1.Text).Date;

将日期插入到列中

如果您不能更改列的数据类型,那么当您从表中读取时,您可以从DATETIME字段获取DATE。


If you can''t change the data type of the column then you can get DATE from the DATETIME field when you read from the table.


这篇关于仅插入日期时间格式的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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