<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to convert Julian Datetime to DateTime? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276891#M55523</link>
    <description>&lt;P&gt;Well, the current date as a SAS date value (number of days after January 1, 1960) is returned by the DATE (or TODAY) function.&amp;nbsp;By default, a date does not contain a time component. To convert a date to a Julian datetime value, you have to specify a time value in addition to the date.&amp;nbsp;In the data step below I use 00:00:00 as the time value, but feel free to replace it by something else (up to 23:59:59).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
t='00:00:00't;
jdt=round((date()*86400+t-'01JAN1970:0:0'dt)*1000);
put jdt= 14.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jun 2016 11:19:19 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-06-13T11:19:19Z</dc:date>
    <item>
      <title>How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276725#M55477</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an issue regarding on converting the Julian datetime to datetime. The data are given below which is in julian datetime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1465538477225&lt;BR /&gt;1465547195922&lt;BR /&gt;1465534266266&lt;BR /&gt;1465546595003&lt;BR /&gt;1465543587493&lt;BR /&gt;1465545693637&lt;BR /&gt;1465531252406&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to ask how am I going to convert thesejulian datetime in&amp;nbsp;ANYDTDTE20. format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 02:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276725#M55477</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2016-06-12T02:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276728#M55478</link>
      <description>&lt;P&gt;What is the definition of those "Julian datetimes"? If they were expressed in seconds, the way SAS datetimes are, they would correspond to more than 46000 years. So they must be expressed in a smaller time unit.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 02:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276728#M55478</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-12T02:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276739#M55480</link>
      <description>&lt;P&gt;Julian Datetime also includes time, the hour, minutes, and seconds. The excel conversion of the following values are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1465538477225 &amp;nbsp;= &amp;nbsp;06/10/2016 06:01:17&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465547195922 &amp;nbsp;= &amp;nbsp;06/10/2016 08:26:36&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465534266266 &amp;nbsp;= &amp;nbsp;06/10/2016 04:51:06&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465546595003 &amp;nbsp;= &amp;nbsp;06/10/2016 08:16:35&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465543587493 &amp;nbsp;= &amp;nbsp;06/10/2016 07:26:27&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465545693637 &amp;nbsp;= &amp;nbsp;06/10/2016 08:01:34&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1465531252406 &amp;nbsp;=&amp;nbsp;06/10/2016 04:00:52&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can I get the datetime values in SAS just like the result in excel?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 04:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276739#M55480</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2016-06-12T04:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276745#M55482</link>
      <description>&lt;P&gt;I don't think SAS has a Julian datetime format or informat. In SAS, you will need to separate the values from Excel into dates and times; you can then translate the date part according to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/38/811.html" target="_blank"&gt;http://support.sas.com/kb/38/811.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 08:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276745#M55482</guid>
      <dc:creator>Norman21</dc:creator>
      <dc:date>2016-06-12T08:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276751#M55483</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65199"&gt;@jei﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your "Julian" datetime values seem to be numbers of milliseconds since January 1, 1970, 00:00:00, which makes the conversion easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input jdt;
dt=jdt/1000+'01JAN1970:0:0'dt;
d=datepart(dt);
t=timepart(dt);
format jdt 14.
       dt  datetime20.
       d   mmddyy10.
       t   e8601tm.;
cards;
1465538477225
1465547195922
1465534266266
1465546595003
1465543587493
1465545693637
1465531252406
;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;jeideegertes wrote:
&lt;P&gt;I want to ask how am I going to convert thesejulian datetime in&amp;nbsp;ANYDTDTE20. format.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;ANYDTDTE20. is an &lt;EM&gt;in&lt;/EM&gt;format, not a format. It cannot be used to read values in your specific datetime format.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 11:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276751#M55483</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-12T11:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276832#M55508</link>
      <description>&lt;P&gt;Hello @FreelanceReinhard,&lt;BR /&gt;&lt;BR /&gt;That what I was looking for. I am also able to convert the other Julian dates.&lt;BR /&gt;&lt;BR /&gt;Thank you very much!&lt;BR /&gt;&lt;BR /&gt;If it is okay, I still have a question. I wanted to get the current date in which the format is similar to the Julian date format. How am I going to extract or get the current date?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 03:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276832#M55508</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2016-06-13T03:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276881#M55520</link>
      <description>&lt;P&gt;You're welcome. So, you want to&amp;nbsp;convert the current datetime to a Julian datetime value (in the sense of&amp;nbsp;&lt;SPAN&gt;milliseconds since January 1, 1970, 00:00:00)?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
jdt=round((datetime()-'01JAN1970:0:0'dt)*1000);
put jdt= 14.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The DATETIME function returns the current datetime as a SAS datetime value (seconds since&amp;nbsp;January 1, 19&lt;STRONG&gt;6&lt;/STRONG&gt;0, 00:00:00). &amp;nbsp;I used the ROUND function to ensure integer results. On my Windows workstation, however, rounding to integers seems to be redundant, because the time precision (DATETIME() values) is limited to milliseconds anyway. I would still use the ROUND function (if I needed&amp;nbsp;integer results) in order to avoid numeric representation issues.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The optional PUT statement writes the result to the log.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 09:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276881#M55520</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-13T09:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276883#M55522</link>
      <description>Hi @FreelanceReinhard,&lt;BR /&gt;&lt;BR /&gt;No, what I mean is I wanted to get the current date. But when I'm getting it the resulted format is in Julian Datetime. That is, what I want is to get the current date (which is in Julian DateTime) in DateTime Function.&lt;BR /&gt;:))</description>
      <pubDate>Mon, 13 Jun 2016 10:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276883#M55522</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2016-06-13T10:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Julian Datetime to DateTime?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276891#M55523</link>
      <description>&lt;P&gt;Well, the current date as a SAS date value (number of days after January 1, 1960) is returned by the DATE (or TODAY) function.&amp;nbsp;By default, a date does not contain a time component. To convert a date to a Julian datetime value, you have to specify a time value in addition to the date.&amp;nbsp;In the data step below I use 00:00:00 as the time value, but feel free to replace it by something else (up to 23:59:59).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
t='00:00:00't;
jdt=round((date()*86400+t-'01JAN1970:0:0'dt)*1000);
put jdt= 14.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 11:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-Julian-Datetime-to-DateTime/m-p/276891#M55523</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-13T11:19:19Z</dc:date>
    </item>
  </channel>
</rss>

