将存储在sql server 2014中的OA日期转换为日期时出错 [英] Error when coverting OA date stored in sql server 2014 into date

查看:142
本文介绍了将存储在sql server 2014中的OA日期转换为日期时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Asp.Net c#应用程序将日期存储在数据库[sql server 2014]中作为OA日期[作为float]。当我试图将db中的日期转换为date(103)格式时,结果日期与我存储的原始日期不同。



我使用了以下查询:



SELECT CAST((CONVERT(float,[DateColumn]))as datetime)AS [Date] FROM MyTable



我应该如何解决这个问题?

解决方案

OADATE使用不同的SQL基准日期(我强烈建议您转移到日期或日期时间,如果可能)。有两天的差异。尝试以下

选择DATEADD(dd,-2,CAST([DateColumn] as datetime))AS [Date] FROM MyTable 


My Asp.Net c# application stores date in database [sql server 2014] as OA date [as float]. and when i tried to convert the date in db into date (103) format, the result date differ from the original date i stored.

I used the following query:

"SELECT CAST((CONVERT(float,[DateColumn])) as datetime) AS [Date] FROM MyTable"

How should i resolve this?

解决方案

OADATE uses a different base date to SQL (I strongly recommend that you move over to Date or Datetime if possible). There is a two day difference. Try the following

select DATEADD(dd, -2, CAST([DateColumn] as datetime)) AS [Date] FROM MyTable


这篇关于将存储在sql server 2014中的OA日期转换为日期时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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