短期存储在数据库中 [英] Short Date Store in DataBase

查看:123
本文介绍了短期存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我选择数据库中的短日期格式,然后从表单中将短日期插入数据库中,但是当我读取数据时,将使用长日期格式.

示例:我在数据库中插入"1390/12/12",但保存了"AM 12:53:00 1390/12/12"

注意:我的数据库中的日期字段格式为:短日期

Hi i Choose Short Date Format in Database , And i Insert Short Date to DataBase From Form , but When i Read Data , its Long Date Format.

Example : i insert "1390/12/12" to DataBase But It Save "AM 12:53:00 1390/12/12"

Note: my Date Field Format in My DataBase is : Short Date

推荐答案

短日期仅是数据的表示形式.而不是它的存储方式.
如果只想将日期时间的日期部分存储在VB中,请使用DateTime.Date(而不是DateTime.Now或默认值).
例如:
Short date is only the presentation of the data. Not how it is stored.
If you want to store only the date portion of your datetime in VB use DateTime.Date (instead of DateTime.Now or the default value).
For example:
Dim dt As Date = DateTime.Now ' dt will now store date AND time, regardless of the date type.
dt = dt.Date ' dt will now be the same date, but it's time value is set to 00:00.


在Access中,似乎必须使用DateValue函数.
请参见此处 [


In Access it seems you have to use the DateValue Function.
See here[^] for more details.
Hope that helps :)


这篇关于短期存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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