<?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: Code to Convert from GMT to CST accounting daylight savings time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958732#M374155</link>
    <description>Thanks for the help Tom</description>
    <pubDate>Fri, 07 Feb 2025 23:03:55 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2025-02-07T23:03:55Z</dc:date>
    <item>
      <title>Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958685#M374136</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I am trying to fix datetime field to convert from GMT time zone to CST time zone. My code doesn't correct for Day light saving time. The daylight savings time will be -5 hrs. Other times it is -6 hrs from GMT time zone. My code does -6 hrs and doesn't take into the daylight savings time. Any help with code is much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data HAVE;
infile datalines;
input START_DATE datetime26.6; 
format START_DATE DATETIME26.6;
datalines;
28JAN2024:21:58:06.423000
06FEB2024:21:23:46.697000
16MAR2024:21:23:45.950000
28APR2024:21:58:03.737000
06MAY2024:21:23:44.590000
28JUN2024:21:58:02.457000
16JUL2024:19:30:09.413000
06AUG2024:21:23:40.557000
16SEP2024:19:30:08.810000
19OCT2024:00:30:08.810000
16NOV2024:05:30:08.810000
06DEC2024:03:23:38.137000
;
run;

data WANTED;
  set HAVE;
  cst_datetime = START_DATE + tzoneoff('CST');
  FORMAT cst_datetime DATETIME26.6;
    TIME_DIFF=START_DATE-cst_datetime;
  FORMAT TIME_DIFF TIME8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 18:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958685#M374136</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2025-02-07T18:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958688#M374139</link>
      <description>&lt;P&gt;Use&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lefunctionsref/n1ien0skr1u9swn1f00w7hizdg9c.htm" target="_self"&gt;TZONEU2S&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  central_time = tzoneu2s(start_date,'America/Chicago');
  format central_time datetime26.6 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS: Do NOT include decimal places in an INFORMAT unless you know that the decimal point was purposely removed from the text to save one byte of storage.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  input START_DATE datetime26.; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are just asking to have your values divided by that power of ten.&amp;nbsp; Might not matter for datetime values but definitely can cause unwanted surprises for normal numbers.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 19:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958688#M374139</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-07T19:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958694#M374143</link>
      <description>&lt;P&gt;I think you want to do 2 things. First, specify the target timezone as a region, not a standard. 'America/Chicago' is for Central.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then also specify the base time in your TZONEOFF function, so the date is taken into account.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data WANTED;
  set HAVE;
  cst_datetime = START_DATE + tzoneoff('America/Chicago',START_DATE);
  FORMAT cst_datetime DATETIME26.6;
    TIME_DIFF=START_DATE-cst_datetime;
  FORMAT TIME_DIFF TIME8.;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;beat me to it with a similar but different answer. More than one way to do this...what could be more SAS than that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 19:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958694#M374143</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2025-02-07T19:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958699#M374147</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then also specify the base time in your TZONEOFF function, so the date is taken into account.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Every day I learn something new in the SAS Communities.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 20:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958699#M374147</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-07T20:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958731#M374154</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;ChrisHemedinger&lt;/SPAN&gt;&lt;/A&gt;&lt;STRONG&gt; , Your code works too. Thank you for all your help.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 23:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958731#M374154</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2025-02-07T23:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Code to Convert from GMT to CST accounting daylight savings time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958732#M374155</link>
      <description>Thanks for the help Tom</description>
      <pubDate>Fri, 07 Feb 2025 23:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-to-Convert-from-GMT-to-CST-accounting-daylight-savings-time/m-p/958732#M374155</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2025-02-07T23:03:55Z</dc:date>
    </item>
  </channel>
</rss>

