问题标签 [datetime2]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 是否可以强制将所有 DateTime 属性建模为 DateTime2?
在 Entity Framework 6 Code First 中,有没有办法强制将所有DateTime
属性建模为DateTime2
?
我知道我能做到
在每个单独DateTime
的属性上,但我想知道是否有办法将其设置为所有 DateTime
属性的默认值。
c# - 如何用 Dapper 插入 DateTime(或 DateTime2)?
我正在尝试执行以下操作:
这是抛出“InvalidCastException”,我相信这是因为日期。我以前在 sql db 中有 endDate 的 datetime2(20) ,将其更改为 datetime 以查看它是否修复它,但没有。任何人都可以帮忙吗?
stored-procedures - Convert DateTime2 to DateTime from Stored Procedure Executed Result
How can i Convert DateTime2 to DateTime from Stored Procedure Executed Result ? I have a procedure which will execute a dynamically formed sql statement which will have an output of various columns in which there are some datetime2 data types. How can I change that datetime2 to datetime because I haev to assign this procedure as data source to a crystal report but crystal report converts datetime2 to string and string can't do required logic in report. So I want the procedure to give datetime rather than datetime2.
I guess temp tables might help me but not sure how to proceed.. please help..
c# - SQL Server 使用 datetime2 查询今天的日期
我有一个 SQL Server 数据库,当我在屏幕上打开它时,我希望它只显示今天添加的记录。
我将日期存储在一个名为 DateAdded 的字段中,它是 DateTime2 数据类型。
我试过这个
这不会显示我认为的任何记录,因为它具有与日期一起存储的时间属性。
我在网上搜索试图找到答案,但似乎没有一个特定于今天添加的记录。
我还需要根据用户输入搜索日期范围,它可以在任何范围内,例如从 09/01/2013 到 18/03/2013 的查看记录。
为此编写sql查询的最佳方法是什么?
编辑 - 我的回答
卡尔给出的答案有效,但我不明白如何更改这些值,所以我可以有不同的日期范围。我虽然应该在这里发布我的最终结果,这是我根据收到的答案发布的,所以它可能会对其他人有所帮助。:)
ms-access - VB6 ADO 命令以美国格式而不是英语插入日期
我有一个 VB6 遗留程序,它一直在悄悄地将 Now() 日期转换为美国格式,即 2013 年 8 月 4 日作为 2013 年 8 月 4 日插入 Access 数据库,但 23/3/2013 很好。这种情况自 2002 年以来一直在发生,但直到现在还没有人注意到。大多数更新是在月底完成的。
如果我提取过程并在虚拟程序中运行它,它工作正常。但是在应用程序代码的某个地方,某些东西正在说服 ADO 尝试转换日期。
它在 ADO 命令中完成,日期设置为 DateTimeStamp 参数
模块的其他地方:
以前有没有人遇到过这种情况,现在为什么会这样?
谢谢
c# - C# / SQL Server : datetime 将 datetime2 数据类型转换为 datetime
数据库表列数据类型为datetime
.
C# 代码我的属性类型是DateTime
但我得到一个错误
将 datetime2 数据类型转换为 datetime 数据类型导致值超出范围。语句已终止。
c++ - 更新 DATETIME 会导致 BB10 上的 sqlite 错误
我用这个查询创建了我的表
然后我像这样插入数据
在这一点上,它工作正常。现在,如果我想运行这样的更新查询,
它在控制台上显示以下错误
但是如果我像这样运行这个更新查询,
现在它工作正常。我不知道更新查询中的 DATETIME('NOW') 语句有什么问题。
c# - 为什么 SQL Server Compact 中的 datetime 类型会舍入值?
我遇到了令我惊讶的事情。
我正在使用WinPcap
从网络上收集数据。在内部,WinPcap
使用 Windows 性能计数器生成其时间戳。我知道它们会发生漂移,但这些时间戳仍然具有精确到微秒级的精度。
如果我将这些时间戳作为datetime
值插入到 SQL Server Compact 4.0 数据库中并稍后提取它们,我注意到精度已降至毫秒。
例如,
现在,我从这里读到SQL Server 将datetime
类型为 0.000、0.003 或 0.007 毫秒的值舍入。这就解释了正在发生的事情。
现在,该datetime
字段使用 8 个字节来存储其数据,4 个字节用于日期,4 个字节用于自午夜以来的毫秒数。但是,如果我调用DateTime.ToBinary()
,我会返回一个 8 字节的数字,该数字代表其所有精度的值。事实上,如果我将这个值写入数据库的bigint
列中,然后DateTime.FromBinary()
在提取该值时调用,我会以相同的精度得到原始值。
这是我要使用的方法,但我还是很好奇:为什么datetime
SQL Server Compact中的原始类型没有使用DateTime
ToBinary/FromBinary的存储机制?
编辑:
正如 Aaron Bertrand 正确指出的那样,SQL Compact 不支持datetime2
. 此外,datetime2
在常规 SQL Server 中使用 6、7 或 8 个字节,而不是 54 个字节。不过,我的基本问题仍然存在。
sql - Converting a table Colum from datetime2 to datetime
I have been assisgned with a starnge assigment where i need to convert 40 tables columns from datetime2 to datetime.
this is the datetime format what i am having in my database.2007-11-12 00:00:00
it contains more than 90,000 records
Please assist
sql - Sql Server Datetime2:消除datetime2中的秒部分
如何消除查询中的秒部分。我使用 DateADD 将秒部分显示为 0 但我只想忽略它。我只想显示日期 hours: minutes 我使用了这个查询,它返回了类似这样的信息
但我只想要2013-09-30 13:03
一部分。
谁能帮我?