SQL Server:将儒略日期转换为YYYY-MM-DD [英] SQL Server : convert Julian Date to YYYY-MM-DD

查看:182
本文介绍了SQL Server:将儒略日期转换为YYYY-MM-DD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了广泛搜索,但似乎找不到将julian转换为yyyy-mm-dd的方法.

I have searched far and wide, but I can't seem find a way to convert julian to yyyy-mm-dd.

这是我朱利安的格式:

Julian格式由年份,前两位数字和一年中的日期,最后三位数字组成.

The Julian format consists of the year, the first two digits, and the day within the year, the last three digits.

例如,95076March 17, 1995. 95表示年份和 076表示这是一年的第76天.

For example, 95076 is March 17, 1995. The 95 indicates the year and the 076 indicates it is the 76th day of the year.

15260

我已经尝试过了,但是没有用:

I have tried this but it isn't working:

dateadd(d,(convert(int,LAST_CHANGED_DATE) % 1000)-1, convert(date,(convert(varchar,convert(int,LAST_CHANGED_DATE) /1000 + 1900) + '/1/1'))) as GrgDate

推荐答案

您可以使用datepart()

SELECT DATEPART(yy, 95076), DATEPART(dy, 95076)

+++ 我误会了一些东西.这是我的更正:+++++

+++ I misunderstood something. Here's my correction: +++++

SELECT DATEADD(day, CAST(RIGHT('95076',3) AS int) – 1, CONVERT(datetime,LEFT('95076',2) + '0101', 112))

这篇关于SQL Server:将儒略日期转换为YYYY-MM-DD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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