简体   繁体   English

在 Silverlake 中将 Julian 日期转换为普通系统日期(使用 SQL 语句)

[英]Convert Julian Date to Normal System Date in Silverlake(USing SQL statement)

I am trying to convert Julian Date to Gregorian/Normal Date(mm/dd/yyyy) in SilverLake DB.我正在尝试在 SilverLake DB 中将 Julian Date 转换为 Gregorian/Normal Date(mm/dd/yyyy)。

I am using Oracle SQL statements to query SilverLake db.我正在使用 Oracle SQL 语句来查询 SilverLake 数据库。 I tried it with:我试过了:

TO_CHAR(<myfieldname>,'YYYYDDD')

But SilverLake DB is throwing me an error:但是 SilverLake DB 给我一个错误:

Argument 1 is not valid for TO_CHAR function参数 1 对 TO_CHAR function 无效

Would appreciate your help.感谢您的帮助。 Thanks in advance.提前致谢。

Just use to_date() to turn the julian date to a date :只需使用to_date()将朱利安日期转换为date

to_date(col, 'j')

Then if you need to represent the date in a given format, you can use to_char() :然后,如果您需要以给定格式表示日期,则可以使用to_char()

to_char(to_date(col, 'j'), 'mm/dd/yyyy')

I am not allowed to post a reply to the previous comment since I am a new user, but this answer also responds there.由于我是新用户,因此不允许我对上一条评论进行回复,但此答案也在那里回复。 What you refer to as SilverLake DB is actually a specific vendor implementation ( Jack Henry & Associates ) of the Db2 for i database, for their SilverLake core banking system.您所说的SilverLake DB实际上是Db2 for i数据库的特定供应商实现( Jack Henry & Associates ),用于他们的SilverLake核心银行系统。 This is the database that comes with the IBM iSeries , a midrange computer also known with it's older name AS/400 (think of a mainframe, just smaller).这是IBM iSeries附带的数据库,这是一款中端计算机,也以其旧名称AS/400 (想想大型机,只是更小一些)而闻名。 While antiquated this is still used for legacy reasons, especially in banking systems such as SilverLake .虽然过时了,但由于遗留原因,它仍然被使用,尤其是在SilverLake等银行系统中。

ORACLE specific commands will NOT work there, other than by coincidence of IBM also using them, and any research you are doing should be referring to Db2 for i , I doubt you will find much content for SilverLake specifically unless you reach to the vendor directly. ORACLE特定命令将无法在那里工作,除了 IBM 也使用它们的巧合之外,您所做的任何研究都应该参考Db2 for i ,我怀疑除非您直接联系供应商,否则您会特别找到SilverLake的很多内容。

I have had luck with the following statement with what you are trying to do:对于您正在尝试做的事情,我对以下陈述感到幸运:

COGSUP.JDTODATE(<myfieldname>)

this will convert the data type to an ISO Date format, in my humble opinion this should be the only date format used on databases.这会将数据类型转换为 ISO 日期格式,在我看来,这应该是数据库上唯一使用的日期格式。

If you still need to convert this to the American notation for presentation purposes, you can wrap this with a to_char statement:如果您仍需要将其转换为美式表示法以进行演示,您可以使用 to_char 语句将其包装起来:

to_char(COGSUP.JDTODATE(<myfieldname>), 'MM/DD/YYYY')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM