为什么在sqldatabase中保存worng日期 [英] Why saving worng date in sqldatabase

查看:61
本文介绍了为什么在sqldatabase中保存worng日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从datetimepicker属性中定制来自fromat dd / MM / yyyy的日期。但是它在数据库中保存了MM / dd / yyyy。它正在保存错误的数据值和月份我无法理解为什么?但是当我将日期保存为2018/03/15时,它保存为2018/15 / 03.当
i想要查看报告时,它可以在我输入日期作为月份和月份作为日期。我可以解决这个问题。请帮助



我尝试过的方法:



在datetimepicker属性中多次更改日期customformat.but它不起作用

i am saving date in custom fromat dd/MM/yyyy from datetimepicker propertis. but it is saving MM/dd/yyyy in database.it is saving wrong values of data and month i can't understand why? but when i save the date as 2018/03/15, it is saved as 2018/15/03.when i want to see a report, it works when i enter day as month and month as day.how can i solve this problem.Please help

What I have tried:

changed date customformat many times in datetimepicker propertis.but it did not work

推荐答案

您好,

日期根据区域设置存储在数据库中,格式是开发人员从数据库表中检索数据时的责任。同样,您不能在数据库中存储十进制类型的货币符号,数据存储为原始
,格式是开发人员的责任。

Dates are stored in a database according to the locale and formatting is the responsibility of the developer when retrieving data out of the database table. Similarly, you can't store a currency symbol for a decimal type in a database, data is stored raw and the formatting is the developer's responsibility.

以下是一个示例: SQL-Server,第一个显示保存在数据库中的Birthday,而第二个和第三个是在完全相同的列上自定义格式化。 

Here is an example for SQL-Server, the first shows Birthday as saved in the database while the second and third are custom formatted on the exact same column. 

因此对于VB.NET应用程序,您在控件中执行格式化,显示日期,例如DateTimePicker,DataGridView等。

So for a VB.NET app, you do the formatting in the control which displays the dates e.g. DateTimePicker, DataGridView etc.


这篇关于为什么在sqldatabase中保存worng日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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