<?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: SAS Date Conversion to Save on Database in Programming 1 and 2</title>
    <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831321#M1184</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/418168"&gt;@dhavalyparikh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That's kind of weird. Now it's giving me 03Jan1960:00:00:00&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can't be.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
next_week = intnx('dtweek',datetime(),1,'b');
format next_week e8601dt19.;
put "next week= " next_week;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 68         
 69         data _null_;
 70         next_week = intnx('dtweek',datetime(),1,'b');
 71         format next_week e8601dt19.;
 72         put "next week= " next_week;
 73         run;
 
 next week= 2022-09-04T00:00:00
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2022 17:48:06 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-08-31T17:48:06Z</dc:date>
    <item>
      <title>SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831307#M1176</link>
      <description>&lt;P&gt;Data _null_;&lt;/P&gt;&lt;P&gt;MyDate = Today();&lt;/P&gt;&lt;P&gt;format MyDate mmddyy10.;&lt;/P&gt;&lt;P&gt;put "Current Date " MyDate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;next_rundate = intnx('week', MyDate, 1,'B');&lt;/P&gt;&lt;P&gt;format next_rundate mmddyy10.&lt;/P&gt;&lt;P&gt;put "next Run Date " next_rundate;&amp;nbsp; &amp;nbsp;/* A - This print correct date after one week in mm/dd/yyyy format*/&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* I want to store value at above line in to below update statement and in database field is date time&amp;nbsp; current below command just store dot (.) in date field - what do I do to convert next_rundate&amp;nbsp; in correct format so I can update thru table */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;update lib.table1&lt;/P&gt;&lt;P&gt;set next_rundate = "&amp;amp;next_rundate" DT&lt;/P&gt;&lt;P&gt;where id =&amp;amp;id.;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831307#M1176</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831310#M1178</link>
      <description>&lt;P&gt;You should not need a macro variable or even two steps to do this. Here is how I would do this, although I haven't tested this at all. It may depend on how next_rundate is formatted in lib.table1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    update lib.table1 set next_rundate = intnx('week',today(),1,'b')
    where id =&amp;amp;id.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831310#M1178</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-31T17:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831315#M1179</link>
      <description>&lt;P&gt;Thanks Miller for you comment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me date in 01JAN1960:06:21:32 format but not one week after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also I would need to store that in macro variable because down the road I have some condition to populate&amp;nbsp;&lt;/P&gt;&lt;P&gt;Week after&amp;nbsp;&lt;/P&gt;&lt;P&gt;Month after&lt;/P&gt;&lt;P&gt;Quater after&lt;/P&gt;&lt;P&gt;Year after&amp;nbsp; &amp;nbsp;and save to database so I will have one update statement with value changing for my multiple if conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831315#M1179</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831316#M1180</link>
      <description>&lt;P&gt;This should fix it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('dtweek',datetime(),1,'b')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no need for a macro variable if the value is stored in a SAS data set, and you just want to find other dates from it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831316#M1180</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-31T17:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831317#M1181</link>
      <description>That's kind of weird. Now it's giving me 03Jan1960:00:00:00&lt;BR /&gt;&lt;BR /&gt;Is there way I can save this value in variable&lt;BR /&gt;and use this along with proc sql update posted on my first question.&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;update lib.table1&lt;BR /&gt;set next_rundate = "&amp;amp;next_rundate" DT&lt;BR /&gt;where id =&amp;amp;id.;&lt;BR /&gt;Run;</description>
      <pubDate>Wed, 31 Aug 2022 17:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831317#M1181</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831319#M1182</link>
      <description>Sorry my bad the command which you sent below that works&lt;BR /&gt;&lt;BR /&gt;intnx('dtweek',datetime(),1,'b')&lt;BR /&gt;but now Is there a way I can save this value in a variable and assign it with my update statement?</description>
      <pubDate>Wed, 31 Aug 2022 17:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831319#M1182</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831320#M1183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/418168"&gt;@dhavalyparikh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry my bad the command which you sent below that works&lt;BR /&gt;&lt;BR /&gt;intnx('dtweek',datetime(),1,'b')&lt;BR /&gt;but now Is there a way I can save this value in a variable and assign it with my update statement?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Explain why you need to save it somewhere, other than in lib.table1 where it is already saved?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831320#M1183</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-31T17:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831321#M1184</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/418168"&gt;@dhavalyparikh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That's kind of weird. Now it's giving me 03Jan1960:00:00:00&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can't be.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
next_week = intnx('dtweek',datetime(),1,'b');
format next_week e8601dt19.;
put "next week= " next_week;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 68         
 69         data _null_;
 70         next_week = intnx('dtweek',datetime(),1,'b');
 71         format next_week e8601dt19.;
 72         put "next week= " next_week;
 73         run;
 
 next week= 2022-09-04T00:00:00
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 17:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831321#M1184</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-31T17:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831322#M1185</link>
      <description>Thanks This works but as I want to have this value to keep on changing the value of dates in one variable and I will have one simple update statement instead of using the case - use if condition first to decide based on type.&lt;BR /&gt;if jtype ='Weekly'&lt;BR /&gt;nextdate = intnx('dtweek',datetime(),1,'b');&lt;BR /&gt;end;&lt;BR /&gt;else if jtype ='yearly'&lt;BR /&gt;nextdate = intnx('year',datetime(),1,'b');&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;update lib.table1 set next_rundate = "&amp;amp;nextdate."DT&lt;BR /&gt;where id =&amp;amp;id.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;something like above.. ?</description>
      <pubDate>Wed, 31 Aug 2022 17:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831322#M1185</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831323#M1186</link>
      <description>the table has one date filed which stores the value of the next_rundate of the job.&lt;BR /&gt;and job can be yearly / monthly/ quarterly / six-monthly - so what I want to do is as and when my job completes it will stamp next_rundate in my table -so we will have a future upcoming job or if next run date not updates during the second run then we know that this job is still not executed.</description>
      <pubDate>Wed, 31 Aug 2022 17:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831323#M1186</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T17:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831327#M1187</link>
      <description>&lt;P&gt;Use a CASE for the value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update lib.table1
set next_rundate = (case
  when jtype = "week" then intnx('dtweek',datetime(),1,'b')
  when jtype = "year" then intnx('dtyear',datetime(),1,'b')
  else .
end)
where id =&amp;amp;id.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2022 18:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831327#M1187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-31T18:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831328#M1188</link>
      <description>Thanks, Kurt, really appreciate your help - I will try and get back to you in a bit. Thanks again.</description>
      <pubDate>Wed, 31 Aug 2022 18:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831328#M1188</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T18:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Conversion to Save on Database</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831330#M1189</link>
      <description>Yes, That works! Awesome! Really appreciate your help.</description>
      <pubDate>Wed, 31 Aug 2022 18:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-Date-Conversion-to-Save-on-Database/m-p/831330#M1189</guid>
      <dc:creator>dhavalyparikh</dc:creator>
      <dc:date>2022-08-31T18:25:20Z</dc:date>
    </item>
  </channel>
</rss>

