JDE 的 Julian Date 格式的精确定义是什么?

发布于 2024-07-29 02:38:08 字数 638 浏览 8 评论 0原文

我正在编写代码以从公历日期转换为 JDE (JDEdwards) Julian日期。

注意:JDE 儒略日期与术语 的正常用法不同儒略日期

据我在 Google 上搜索到的,JDE 儒略日期的定义是:

1000*(year-1900) + dayofyear

其中年份是 4 位数的年份(例如 2009 年),而 dayofyear 是 1 表示 1 月 1 日,并将全年计数为 12 月 31 日的 365 或 366(取决于这是否是闰年)。

我的问题是:是否支持 1900 年之前的年份? 如果是这样,上面的公式是否仍然成立,或者应该是这样的:(

1000*(year-1900) - dayofyear

注意减号而不是加号。)

或其他什么?

有人有此日期格式的官方文档的链接吗?

I am writing code to convert from a Gregorian date to a JDE (J.D.Edwards) Julian date.

Note: a JDE Julian date is different from the normal usage of the term Julian date.

As far as I can work out from Googling, the definition of a JDE Julian date is:

1000*(year-1900) + dayofyear

where year is the 4-digit year (e.g. 2009), and dayofyear is 1 for 1st January, and counts up all year to either 365 or 366 for 31st December (depending whether this is a leap year).

My question is this: are years before 1900 supported? If so, does the above formula still hold, or should it be this:

1000*(year-1900) - dayofyear

(note minus instead of plus.)

or something else?

Does anyone have a link to the official documentation for this date format?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

忆梦 2024-08-05 02:38:08

JDE 儒略日期由 CYYDDD 组成,即世纪、年份、年份。

世纪为零表示 20 世纪,例如 19XX,世纪为 1 表示 21 世纪,例如 20XX。

年份是两位数。
因此 101001 是 2001 年 1 月 1 日

如您所见,这不支持 1900 年之前的日期。

请参阅此 Oracle 页面以获取简单且官方的解释:关于儒略日期格式

The JDE Julian date consists of CYYDDD which is Century, Year, Day of year.

Century is zero for 20th e.g. 19XX and one for 21st e.g. 20XX.

The year is two digits.
So 101001 is 1 January 2001

As you can see this will not support dates before 1900.

See this Oracle page for a simple and official explanation: About the Julian Date Format

℉服软 2024-08-05 02:38:08

"JDE Julian Date Converter" 确实返回负值:

1809/07/23 : -90635

经典朱利安日期

The Julian date for CE  1809 July 23 00:00:00.0 UT is
JD 2381986.50000

这是 JD 的示例EDWARDS(AS/400 软件)Julian Date,但这不是“官方”文档,而且它似乎不支持 1900 年之前的日期...

注意:此“ACC:如何在访问和返回中将儒略日转换为日期" 不支持 1900 年之前的日期要么......因为它谈到“非正式”儒略日,政府机构和承包商常用

本文中使用的非正式儒略日格式是一年中的第几天(例如,儒略日 032 表示 2 月 1 日,或一年中的第 32 天)。
非正式儒略日格式的变体包括使用前面的两位数年份(例如 96032 表示 2/1/96)并用破折号分隔年份(例如 96-032)。
另一种不太流行的儒略日格式使用一位数年份(例如 6-032)。 这些附加格式并不唯一标识世纪或十年。 使用这些格式时应仔细考虑后果; 例如,儒略日 00061 可解释为 3/1/2000 或 3/2/1900。

The "JDE Julian Date Converter" does return a negative value for:

1809/07/23 : -90635

As opposed to the classical Julian Date:

The Julian date for CE  1809 July 23 00:00:00.0 UT is
JD 2381986.50000

Here is a example of JD EDWARDS (AS/400 software) Julian Date, but that is not an "official" documentation and it does not seems to support dates before 1900...

Note: this "ACC: How to Convert Julian Days to Dates in Access and Back" does not support date before 1900 either... as it speaks about an "informal" Julian day, commonly used by government agencies and contractors.

The informal Julian day format used in this article is the ordinal day of a year (for example, Julian day 032 represents February 1st, or the 32nd day of the year).
Variations on informal Julian day formats include using a preceding two-digit year (for example 96032 for 2/1/96) and separating the year with a dash (for example 96-032).
Another, less popular, Julian day format uses a one digit year (for example 6-032). These additional formats do not uniquely identify the century or decade. You should carefully consider the consequences when using these formats; for example, the Julian day 00061 can be interpreted as 3/1/2000 or 3/2/1900.

风轻花落早 2024-08-05 02:38:08

更新:抱歉,JDE 可能是别的东西。 但供参考:

我所知道的JDE是不同的。 从本书第59页开始
“天文算法”(Jean Meeus,ISBN 0-943396-35-2):

“如果JD对应的是一个瞬间
以动态尺度来衡量
时间(或星历时间),
表达式 朱利安星历日
一般使用(JDE)。 (不是 JED
有时会这样写。 “E”是一个
附加到“JD”的索引排序)”

JD 和 JDE(同一时间点)的值接近
因为 UT 和 ET 之间的差异约为分钟。 例如,1990 年 ET-UT 为 56.86 秒,1900 年为 -2.72 秒。

还有 MJD(修正儒略日):

MJD = JD - 2400000.5

MJD 的零点是 1858-11-17,0h UT。


请注意,将 JD 作为儒略日期是用词不当。 这是
朱利安。 JD与朱利安无关
日历。 (这与维基百科的文章不一致,这个
来自上述书的作者 Jean Meeus - 一位专门研究天体力学的比利时天文学家.)

Update: Sorry, JDE is probably something else. But for reference:

The JDE I know is different. From page 59 in the book
"Astronomical algorithms" (Jean Meeus, ISBN 0-943396-35-2):

"If the JD corresponds to an instant
measured in the scale of Dynamical
Time (or Ephemeris Time), the
expression Julian Ephemeris Day
(JDE) is generally used. (Not JED as
it is sometimes written. The 'E' is a
sort of index appended to 'JD')"

JD and JDE (for the same point in time) are close in value
as the difference UT and ET is on the order of minutes. E.g. ET-UT was 56.86 seconds in 1990 and -2.72 seconds in 1900.

There is also MJD (Modified Julian Day):

MJD = JD - 2400000.5

Zero point for MJD is 1858-11-17, 0h UT.


Note that JD as Julian date is a misnomer. It is
Julian day. The JD has nothing to do with the Julian
calendar. (This is in disagreement with the Wikipedia article, this
is from the author of the book mentioned above, Jean Meeus - a Belgian astronomer specializing in celestial mechanics.)

维持三分热 2024-08-05 02:38:08

也许偏离了问题,您可以使用以下公式在 Excel 中进行转换:

在 Excel 中将儒略转换为日期

在单元格 A2 中放置一个儒略日期,例如 102324
在单元格 B2 中放置此公式:(将其复制进去)
=DATE(年("01/01/"&TEXT(1900+INT(A2/1000),0)),MONTH("01/01/"&TEXT(1900+INT(A2/1000)) ),0)),DAY("01/01/"&TEXT(1900+INT(A2/1000),0)))+MOD(A2,1000)-1

日期 11/20/ 02 日期将出现在单元格 B2 中

在 Excel 中将日期转换为儒略历

在单元格 C2 中复制以下公式:
=(YEAR(B2)-2000+100)*1000+B2-DATE(YEAR(B2),"01","01")+1

这会将 B2 转换回 102324

Maybe off from the question, you can convert in Excel using the following formula:

Convert Julian to Date in Excel

In Cell A2 place a Julian date, like 102324
in Cell B2 place this formula: (copy it in)
=DATE(YEAR("01/01/"&TEXT(1900+INT(A2/1000),0)),MONTH("01/01/"&TEXT(1900+INT(A2/1000),0)),DAY("01/01/"&TEXT(1900+INT(A2/1000),0)))+MOD(A2,1000)-1

The date 11/20/02 date will appear in cell B2

Convert Date to Julian in Excel

In Cell C2 copy this formula:
=(YEAR(B2)-2000+100)*1000+B2-DATE(YEAR(B2),"01","01")+1

This will convert B2 back to 102324

将以下源代码保存在名为 JDEDATES 的源成员中。 在第一行使用 runsqlstm 创建函数。 类的操作

select  jde2date(A1UPMJ), f.* from f00095 f                            

然后,您可以执行诸如查看真实约会之

。 来源:

--RUNSQLSTM SRCFILE(qtxtsrc) SRCMBR(JDEDATES) COMMIT(*NONE)  NAMING(*SQL) 
 -- jde 2 date                                                                    

 create function QGPL/jde2date ( d decimal(7,0))                                  
 returns date                                                                     
 language sql                                                                     
 deterministic                                                                    
 contains sql                                                                     
    SET OPTION DATFMT=*ISO                                                        
 BEGIN                                                                            
  if d=0 then return null;                                                        
  else                                                                            
       return date(digits(decimal(d+1900000,7,0)));                               
  end if;                                                                         
 end;                                                                            -- date 2 jde                                     
 create function QGPL/date2jde ( d date)           
 returns decimal(7,0)                              
 language sql                                      
 deterministic                                     
 contains sql                                      
    SET OPTION DATFMT=*ISO                         
 BEGIN                                             
  if d is null then return 0;                      
  else                                             
  return (YEAR(D)-1900)*1000+DAYOFYEAR(D);         
  end if;                                          
 end ;                                              

Save the below source code in a source member called JDEDATES. Use the runsqlstm on the first line to create the functions. You can then do things like

select  jde2date(A1UPMJ), f.* from f00095 f                            

and see a real date.

Source:

--RUNSQLSTM SRCFILE(qtxtsrc) SRCMBR(JDEDATES) COMMIT(*NONE)  NAMING(*SQL) 
 -- jde 2 date                                                                    

 create function QGPL/jde2date ( d decimal(7,0))                                  
 returns date                                                                     
 language sql                                                                     
 deterministic                                                                    
 contains sql                                                                     
    SET OPTION DATFMT=*ISO                                                        
 BEGIN                                                                            
  if d=0 then return null;                                                        
  else                                                                            
       return date(digits(decimal(d+1900000,7,0)));                               
  end if;                                                                         
 end;                                                                            -- date 2 jde                                     
 create function QGPL/date2jde ( d date)           
 returns decimal(7,0)                              
 language sql                                      
 deterministic                                     
 contains sql                                      
    SET OPTION DATFMT=*ISO                         
 BEGIN                                             
  if d is null then return 0;                      
  else                                             
  return (YEAR(D)-1900)*1000+DAYOFYEAR(D);         
  end if;                                          
 end ;                                              
风流物 2024-08-05 02:38:08

晚了几年,但对于像我这样发现自己正在使用这样的遗留系统的其他人来说,我希望我的一些 java 片段可以有所帮助。 我利用的事实是,您可以将此 CYYDDD 格式转换为 yyyyDDD 格式并基于该格式进行解析。

    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.Calendar;
    import java.util.SimpleDateFormat;
    
    String jdeJulianDate = "099365"; //Testing with December 31, 1999
    
    // Compile what the year number is
    int centIndex = Integer.parseInt(jdeJulianDate.substring(0,1));
    int yearIndex = Integer.parseInt(jdeJulianDate.substring(1,3));
    int yearNumber = 1900 + (100 * centIndex) + yearIndex;
    
    // Put the year number together with date ordinal to get yyyyDDD format
    String fullDate = String.valueOf(yearNumber) + jdeJulianDate.substring(3,6);
    
    // Date parsing, so need to wrap in try/catch block
    try {
        Date dt = new SimpleDateFormat("yyyyDDD").parse(fullDate);
        // Validate it parses to a date in the same year...
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        if (cal.get(Calendar.YEAR) != yearNumber) {
            // Cases happen where things like 121366 (should be invalid) get parsed, yielding 2022-01-01.
            // Throw exception or what-not here.
        }
    }
    catch (Exception e) {
        // Date parsing error handling here
    }

Several years late to the party, but for other folks like me that find yourselves working with legacy systems like this, I hope some of my java snippets can help. I'm leveraging the fact that you can convert this CYYDDD format into yyyyDDD format and parse based on that.

    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.Calendar;
    import java.util.SimpleDateFormat;
    
    String jdeJulianDate = "099365"; //Testing with December 31, 1999
    
    // Compile what the year number is
    int centIndex = Integer.parseInt(jdeJulianDate.substring(0,1));
    int yearIndex = Integer.parseInt(jdeJulianDate.substring(1,3));
    int yearNumber = 1900 + (100 * centIndex) + yearIndex;
    
    // Put the year number together with date ordinal to get yyyyDDD format
    String fullDate = String.valueOf(yearNumber) + jdeJulianDate.substring(3,6);
    
    // Date parsing, so need to wrap in try/catch block
    try {
        Date dt = new SimpleDateFormat("yyyyDDD").parse(fullDate);
        // Validate it parses to a date in the same year...
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        if (cal.get(Calendar.YEAR) != yearNumber) {
            // Cases happen where things like 121366 (should be invalid) get parsed, yielding 2022-01-01.
            // Throw exception or what-not here.
        }
    }
    catch (Exception e) {
        // Date parsing error handling here
    }
小姐丶请自重 2024-08-05 02:38:08

在 JDE Julian Date 和 Gregorian Date 之间来回转换的 VBA 代码示例:

Public Const Epoch = 1900
Public Const JDateMultiplier = 1000
Public Const FirstJan = "01/01/"

Public Function Julian2Date(ByVal vDate As Long) As Date

    Dim Year As Long
    Dim Days As Long
    Dim SeedDate As Date

    '   Day Number
    Days = vDate - (Int(vDate / JDateMultiplier) * JDateMultiplier) - 1
    '   Calendar Year
    Year = ((vDate - Days) / JDateMultiplier) + Epoch
    '   First Day of Calendar Year
    SeedDate = CDate(FirstJan + CStr(Year))

    '   Add Number of Days to First Day in Calendar Year
    Julian2Date = DateAdd("d", Days, SeedDate)

End Function

Public Function Date2Julian(ByVal vDate As Date) As Long

    Dim JYear As String
    Dim BeginDate As Date
    Dim JDays As Long

    '   Calendar Year
    JYear = Format(Year(vDate), "0000")
    '   First Day of Calendar Year
    BeginDate = CDate(FirstJan + JYear)
    '   Day Number
    JDays = DateDiff("d", BeginDate, vDate) + 1

    '   Add Number of Days to Year Number
    Date2Julian = ((CLng(JYear) - Epoch) * JDateMultiplier) + JDays

End Function

我试图使其尽可能清晰和简单,为此我故意省略了任何错误捕获。 但是,您应该能够将代码添加到 VBA 模块并直接从您自己的代码中调用它们。

我还包括一些有用的 T-SQL 片段:

今天日期为 JDE 儒略日期:

 (datepart(yy,getdate())-1900) * 1000 + datepart(dy, getdate())

将 JDE 儒略日期转换为公历 (DD/MM/YYYY),将 XXXXXX 替换为包含 JDE 儒略日期的列名称:

convert (varchar, dateadd (day,convert (int, right(XXXXXX,3)) - 1, convert (datetime, ('1/1/' + convert ( varchar, (cast(left(right(XXXXXX+1000000,6),3) as varchar) + 1900))))),103)

如果您需要不同的公历格式,将 103 值(位于末尾)替换为此处找到的适用值: https://msdn.microsoft.com/en-us/library/ms187928.aspx

A sample of VBA code to convert back and forth between JDE Julian Date and Gregorian:

Public Const Epoch = 1900
Public Const JDateMultiplier = 1000
Public Const FirstJan = "01/01/"

Public Function Julian2Date(ByVal vDate As Long) As Date

    Dim Year As Long
    Dim Days As Long
    Dim SeedDate As Date

    '   Day Number
    Days = vDate - (Int(vDate / JDateMultiplier) * JDateMultiplier) - 1
    '   Calendar Year
    Year = ((vDate - Days) / JDateMultiplier) + Epoch
    '   First Day of Calendar Year
    SeedDate = CDate(FirstJan + CStr(Year))

    '   Add Number of Days to First Day in Calendar Year
    Julian2Date = DateAdd("d", Days, SeedDate)

End Function

Public Function Date2Julian(ByVal vDate As Date) As Long

    Dim JYear As String
    Dim BeginDate As Date
    Dim JDays As Long

    '   Calendar Year
    JYear = Format(Year(vDate), "0000")
    '   First Day of Calendar Year
    BeginDate = CDate(FirstJan + JYear)
    '   Day Number
    JDays = DateDiff("d", BeginDate, vDate) + 1

    '   Add Number of Days to Year Number
    Date2Julian = ((CLng(JYear) - Epoch) * JDateMultiplier) + JDays

End Function

I have tried to make it as clear and simple as possible, and to this end I have intentionally left out any error trapping. However, you should be able to add the code to a VBA module and call them directly from your own code.

I also include some useful snippets of T-SQL:

Todays Date as JDE Julian Date:

 (datepart(yy,getdate())-1900) * 1000 + datepart(dy, getdate())

Convert JDE Julian Date to Gregorian (DD/MM/YYYY), replace XXXXXX with the column name containing the JDE Julian Date:

convert (varchar, dateadd (day,convert (int, right(XXXXXX,3)) - 1, convert (datetime, ('1/1/' + convert ( varchar, (cast(left(right(XXXXXX+1000000,6),3) as varchar) + 1900))))),103)

If you require a different Gregorian format, replace the 103 value (right at the end) with the applicable value found here: https://msdn.microsoft.com/en-us/library/ms187928.aspx

因为看清所以看轻 2024-08-05 02:38:08

如果有人感兴趣的话,我有一个简单的方法让 C 使用现在和纪元 1970, 01, 01 午夜。
但这是针对儒略日数字的,它与 JDE 不同,但它们在使用数学来计算天数方面是相似的,我确信这个想法可以适用于 JDE。 有时人们就像我一样混淆了两者。 对不起。 但这仍然是一个使用时间参考的示例,应该始终这样做,并且由于大多数计算机都使用它,因此我们很容易不要陷入日期的泥沼,而只需使用该纪元之前或之后的天数。

由于 JDE 现在归 Oracle 所有,因此它们现在也支持 Julian_Day。 看:
https://docs.oracle.com/javase /8/docs/api/java/time/temporal/JulianFields.html

#include <stdio.h>
#include <time.h>
#define EPOCH (double)  2440587.5 /* Julian Day number for Jan. 01, 1970 midnight */
int main ()
{
 double days = time(0)/86400.0;

 printf ("%f days since January 1, 1970\n", days);

 printf ("%f\n", days + EPOCH);

 return 0;  
}

I have an easy way for C using time now and epoch 1970, 01, 01 midnight if anybody is interested.
But this is for Julian Day Numbers which is not the same as JDE but they are similar in respect to using math to compute days and I'm sure this idea could be adapted for JDE. Sometimes people just confuse the two like I do. Sorry. But still this is an example of using a time reference which should always be done and since most computers use this it would be just as easy for us not to get too bogged down in dates and just use days before or after this epoch.

Since JDE is now owned by Oracle, they also now support Julian_Day. see:
https://docs.oracle.com/javase/8/docs/api/java/time/temporal/JulianFields.html

#include <stdio.h>
#include <time.h>
#define EPOCH (double)  2440587.5 /* Julian Day number for Jan. 01, 1970 midnight */
int main ()
{
 double days = time(0)/86400.0;

 printf ("%f days since January 1, 1970\n", days);

 printf ("%f\n", days + EPOCH);

 return 0;  
}
笑脸一如从前 2024-08-05 02:38:08

哇,其中一些答案中有很多复杂的代码,只是为了在 JDE 朱利安日期之间进行转换。 Excel 和 VBA 中有一些简单的方法可以实现这一目标。

FROM JULIAN

Excel(假设儒略日期位于 A1 中):

=DATE(1900+LEFT(A1,LEN(A1)-3),1,RIGHT(A1,3))

VBA(来自儒略日期 j,存储为字符串):

d = DateSerial(1900 + Left$(j, Len(j) - 3), 1, Right$(j, 3))

VBA(来自儒略日期 j,存储为长整型):

d = DateSerial(1900 + Left$(j, Len(CStr(j)) - 3), 1, Right$(j, 3))

TO JULIAN

Excel(假设日期位于 A1 中):

=(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0)

VBA (对朗,j):

j = (Year(d) - 1900) * 1000 + DatePart("y", d)

Wow, there's a lot of complicated code in some of these answers just to convert to and from JDE julian dates. There are simple ways in Excel and VBA to get there.

FROM JULIAN

Excel (assuming julian date is in A1):

=DATE(1900+LEFT(A1,LEN(A1)-3),1,RIGHT(A1,3))

VBA (from julian date, j, stored as String):

d = DateSerial(1900 + Left$(j, Len(j) - 3), 1, Right$(j, 3))

VBA (from julian date, j, stored as Long):

d = DateSerial(1900 + Left$(j, Len(CStr(j)) - 3), 1, Right$(j, 3))

TO JULIAN

Excel (assuming date is in A1):

=(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0)

VBA (to a Long, j):

j = (Year(d) - 1900) * 1000 + DatePart("y", d)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文