<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Adding days to a date value and inserting the new value into a date field</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Adding-days-to-a-date-value-and-inserting-the-new-value-into-a-date-field-79874</link>
        <description></description>
        <pubDate>Wed, 07 Oct 2026 17:37:02 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Adding-days-to-a-date-value-and-inserting-the-new-value-into-a-date-field-79874" rel="self" type="application/rss+xml" />

                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2236037#post2236037</link>
          <description><![CDATA[<p>Will do.</p>
<p>And thanks for all your help.</p>
<p>Jerry Kornbluth</p>
]]></description>
          <pubDate>Wed, 11 Feb 2015 15:59:01 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2236037#post2236037</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2236032#post2236032</link>
          <description><![CDATA[<p>Hi Jerry</p>
<p>I've got nothing written up, sorry. This would be considered a custom addition, though it's likely a pretty quick one. Can you email Ross at consulting@interactivetools.com with a link to this thread? </p>]]></description>
          <pubDate>Wed, 11 Feb 2015 13:21:52 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2236032#post2236032</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2236028#post2236028</link>
          <description><![CDATA[<p>Sounds like a more elegant solution, Claire,</p>
<p>I know I'm pushing the envelope, but could you offer any code snippet that I could use to do this? </p>
<p>I'm feeling very programming challenged by this for some reason. (I think I always feel challenged about working with dates.)</p>
<p>Thanks,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Wed, 11 Feb 2015 11:44:55 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2236028#post2236028</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2236026#post2236026</link>
          <description><![CDATA[<p>Hey Jerry</p>
<p>I think you're overthinking this. You already know that the renewal date will be September 30th or October 1st, yeah? It's only the year that changes. So your code doesn't need to add on a certain number of days - you effectively only need to work out what year it should be in.</p>
<p>I think some PHP logic should sort this out - as in, looking at the current time, working out whether it's before or after January 1st, and then setting the year manually instead of using the date function.</p>]]></description>
          <pubDate>Wed, 11 Feb 2015 10:54:38 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2236026#post2236026</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2236015#post2236015</link>
          <description><![CDATA[<p>Hi Claire,<br /><br />Sorry to come back to this, but I’m still trying to add one year (or multiple years) to an expiresDate and can’t lick it.<br /><br />Here’s where I’m at so far...<br /><br />I tried the adding seconds using strtotime as you suggested, and I come up with a leap year issue because the new date is one day short for leap years. (Oct 1, 2015 becomes Sept 30, 2016 and  Sept 30, 2019 becomes Sept 29, 2020, etc.)</p>
<p><code>&lt;?php $current_expiration = $CURRENT_USER['expiresDate'] ?&gt;<br />   &lt;?php $expires_date_plus_1_year = date('Y-m-d H:i:s', strtotime($current_expiration) + 60*60*24*365); ?&gt;<br /> &lt;?php <br />   mysqlStrictMode(false);<br />  mysql_query("UPDATE `{$TABLE_PREFIX}accounts`    <br />     SET <br />     expiresDate       = '".mysql_escape($expires_date_plus_1_year)."'<br />    WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'")  <br />        or die("MySQL Error:&lt;br/&gt;\n". htmlspecialchars(mysql_error()) . "\n");  <br />         $userNum = mysql_insert_id();  <br />     // redirect after a successful update  <br />     header("Location:  $masterurl/renewal-confirmation.php"); <br />  ?&gt;</code></p>
<p><br />Then I tried using add_date and it throws the following mySQL error<br /><br />You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_ADD('2020-09-29 00:00:00', INTERVAL 5 YEAR); WHERE num = '4'' at line 3</p>
<p>(the date 2020-09-29 is correct, as is the user number '4")</p>
<p><code> &lt;?php $current_expiration = $CURRENT_USER['expiresDate'] ?&gt;<br /> &lt;?php <br />   mysqlStrictMode(false);<br />  mysql_query("UPDATE `{$TABLE_PREFIX}accounts`    <br />     SET <br />      DATE_ADD('$current_expiration', INTERVAL 5 YEAR);<br />    WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'")  <br />        or die("MySQL Error:&lt;br/&gt;\n". htmlspecialchars(mysql_error()) . "\n");  <br />         $userNum = mysql_insert_id();  <br />     // redirect after a successful update  <br />     header("Location:  $masterurl/renewal-confirmation.php"); <br />  ?&gt;</code></p>
<p><br />Any thoughts?<br /><br />Thanks,<br /><br />Jerry Kornbluth</p>]]></description>
          <pubDate>Wed, 11 Feb 2015 07:08:16 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2236015#post2236015</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235805#post2235805</link>
          <description><![CDATA[<p>I'd probably need a while to code up something that works, but the basic jist of it is that you'd get the current UNIX timestamp from time(), get your cutoff date and turn it into another timestamp using strtotime(), then check if the current timestamp is before or after it. Then you'd manually set the expiresDate to a specific date and time instead of trying to add on a year or more.</p>]]></description>
          <pubDate>Tue, 20 Jan 2015 14:05:12 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235805#post2235805</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235804#post2235804</link>
          <description><![CDATA[<p>Hi Claire,</p>
<p>Can you offer a basic coding format to start with?</p>
<p>(You're so good at this...)</p>
<p>Thanks,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Tue, 20 Jan 2015 13:44:30 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235804#post2235804</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235803#post2235803</link>
          <description><![CDATA[<p>Yeah, I think so. If you don't have to calculate it on the fly, then it does get easier.</p>
<p>Hardcoded checks are not ideal, but they'll be fine as long as you've only got a couple to deal with.</p>]]></description>
          <pubDate>Tue, 20 Jan 2015 12:51:58 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235803#post2235803</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235802#post2235802</link>
          <description><![CDATA[<p>Thanks Claire,</p>
<p>Could I use Sept 30 as a fixed value and add 1 or 2 to the year value depending on which part of the year they renewed in?</p>
<p>Thanks,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Tue, 20 Jan 2015 12:35:04 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235802#post2235802</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235799#post2235799</link>
          <description><![CDATA[<p>No easy way that I know of, sorry Jerry. It's definitely possible, but it'd be a custom function to check if February 29th falls within the bounds of the added time.</p>
<p>Adding time using the UNIX timestamp and a string of multiplication is really the simplest method of doing it, unfortunately.</p>]]></description>
          <pubDate>Tue, 20 Jan 2015 10:27:52 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235799#post2235799</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235796#post2235796</link>
          <description><![CDATA[<p>Hi Claire,</p>
<p>I feel like I'm pushing my luck by asking, but is there an easy way to add one year (or 2 years) to the expiresDate to a specific date without a long string of multiplication operatives?</p>
<p>Possibly one that takes into account that dreaded leap year calculation?</p>
<p>So for example, if a membership cycle is Oct 1 - September 30, and someone renews in the first half of the cycle (October 1 - March 31), they get renewed through September 30 of the next year.</p>
<p>If they renew in the second half of the cycle (On or after April 1) they get renewed through September 30 of the second year.</p>
<p>Thanks,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Mon, 19 Jan 2015 18:38:19 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235796#post2235796</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235794#post2235794</link>
          <description><![CDATA[<p>Thank you Claire,</p>
<p>That works perfectly.</p>
<p>It's so easy when you know how....</p>
<p>Best,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Mon, 19 Jan 2015 16:17:26 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235794#post2235794</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235790#post2235790</link>
          <description><![CDATA[<p>Hey Jerry, try this:</p>
<p><code>$end_date_plus_7_days = date('Y-m-d H:i:s', strtotime($event_end_date) + 60*60*24*7); </code></p>]]></description>
          <pubDate>Mon, 19 Jan 2015 15:38:12 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235790#post2235790</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235783#post2235783</link>
          <description><![CDATA[<p>Looking forward to the answers..</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Fri, 16 Jan 2015 19:45:45 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235783#post2235783</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235782#post2235782</link>
          <description><![CDATA[<p>Jerry:  You had to ask the hard question!</p>
<p>That is exactly what i am working on in my database.  For now, I used phpMyAdmin to do it manually.</p>
<p>As soon as I figure it out I will respond to the post.</p>
<p>Ragi</p>
<p>P.S.  BTW, have you every heard of phpGrid? (<a href="http://phpgrid.com" rel="nofollow">http://phpgrid.com</a>)  Worth a look.</p>]]></description>
          <pubDate>Fri, 16 Jan 2015 17:31:18 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235782#post2235782</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235781#post2235781</link>
          <description><![CDATA[<p>Hi Ragi,</p>
<p>Appreciate your looking at this.</p>
<p>I'm not too good at mysql syntax. Where would you insert that code in the above?</p>
<p>Thanks,</p>
<p>Jerry Koirnbluh</p>]]></description>
          <pubDate>Fri, 16 Jan 2015 17:12:04 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235781#post2235781</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235779#post2235779</link>
          <description><![CDATA[<p>Jerry:  have you tried using the following SQL:</p>
<p><code>UPDATE tablename SET fieldname1 = fieldname2 + INTERVAL 7 DAY;</code></p>
<p>I have used it with + 1 YEAR.  You may need to check the syntax to confirm is "DAY"</p>
<p>So you should be able to do this:</p>
<p><code>UPDATE tablename SET removeDate = event_end_date + INTERVAL 7 DAY;</code></p>
<p>Tell me if it works!</p>
<p>Ragi</p>]]></description>
          <pubDate>Fri, 16 Jan 2015 14:51:51 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235779#post2235779</guid>
        </item>
                <item>
          <title>Adding days to a date value and inserting the new value into a date field</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2235778#post2235778</link>
          <description><![CDATA[<p>Hi All,<br /><br /> I’m trying to use one date value in a form to insert 2 date values into a new record. The date fields are called event_end_date and removeDate.<br /><br /> If an event_end_date is entered in the form, on submission I want to:<br /> A)  enter that date in the event_end_date field <br /> B)  add 7 days to that date and enter the new date into the removeDate field <br /><br /> *** I can’t figure out how Accomplish step “B”</p>
<p>Thanks for your help,</p>
<p>Jerry Kornbluth<br />  <br /> Here’s the code I’m using so far.<br /><br /> Near the top of the page to define variables:</p>
<p><code>  $event_end_date = date("Y-m-d",mktime(0,0,0,@$_REQUEST['month_2'],@$_REQUEST['day_2'],@$_REQUEST['year_2']));  //Works to populate the event_end_date field</code></p>
<p>And, I’ve tried both:</p>
<p><code> $end_date_plus_7_days =date("Y-m-d", strtotime($event_end_date . " +7 day"); <br /> and<br /> $end_date_plus_7_days = strtotime(date("Y-m-d", strtotime($event_end_date)) . " +7 day");</code></p>
<p>but neither work to populate the removeDate field</p>
<p><br /> In my mysql insert I’m using:</p>
<p><code>event_end_date    = '".mysql_escape($event_end_date)."', <br /> and <br /> removeDate     = '".mysql_escape($end_date_plus_7_days)."',</code></p>
<p><br /><br />And in the form I'm using:</p>
<p><code>&lt;tr&gt;<br />               &lt;td class="body-text-bold-9"&gt;Event End Date&lt;/td&gt;<br />               &lt;td&gt; Month:<br />                 &lt;select name="month_2"&gt;<br />                   &lt;?php foreach(range(1,12) as $month_2): ?&gt;<br />                   &lt;option value="&lt;?php echo $month_2;?&gt;"&gt;&lt;?php echo date("F",strtotime("0000-$month_2"));?&gt;&lt;/option&gt;<br />                   &lt;?php endforeach ?&gt;<br />                 &lt;/select&gt;<br />                 Day:<br />                 &lt;select name="day_2"&gt;<br />                   &lt;?php foreach(range(1,31)as $day_2): ?&gt;<br />                   &lt;option value="&lt;?php echo $day_2;?&gt;"&gt;&lt;?php echo $day_2;?&gt;&lt;/option&gt;<br />                   &lt;?php endforeach ?&gt;<br />                 &lt;/select&gt;<br />                 Year:<br />                 &lt;select name="year_2"&gt;<br />                   &lt;?php foreach (range($lowestYear,$highestYear) as $year_2):?&gt;<br />                   &lt;option value="&lt;?php echo $year_2;?&gt;"&gt;&lt;?php echo $year_2;?&gt;&lt;/option&gt;<br />                   &lt;?php endforeach?&gt;<br />                 &lt;/select&gt;&lt;/td&gt;<br />             &lt;/tr&gt;</code></p>
]]></description>
          <pubDate>Fri, 16 Jan 2015 14:17:53 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2235778#post2235778</guid>
        </item>
              </channel>
    </rss>
  