close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Auto Calculating a date in the future

Thread began 1/24/2011 5:57 pm by Brad Lawryk | Last modified 1/25/2011 3:36 pm by Brad Lawryk | 854 views | 5 replies |

Brad Lawryk

Auto Calculating a date in the future

Hi guys,

I have a form now that simply has one field to enter a date and it updates the date in the table. Easy as Pie.

But I also need it to update a second field in the table with the entered date plus 180 days in the future. I can get it to enter the same date in both fields real easy (Starting to really like Data Assist) but can't figure out how to add the 180 days to it.

Ideas?

Sign in to reply to this post

Ray BorduinWebAssist

This would probably do it:

<?php echo(strtotime($_POST['yourfield'] . " +180 day")); ?>

But you could probably add the 180 days when you query it and not even use an extra field in the database if it will always be 180 days from an existing date there is really no reason to store it at all since you can use SQL to get it from the query without ever storing the field.

Sign in to reply to this post

Brad Lawryk

Thanks Ray,

Yeah I could just get the value in a Query. But in this case the way that it is being used and how often, it is just so much easier to have a second field in the table.

Mainly because it will default it to the 180 days when entering ... but yet still remain editable on a record by record basis.

Again, thanks for your help. I knew there had to be a way with Data Assist. I'll give that a try.

Brad

Sign in to reply to this post

Brad Lawryk

Well, that didn't work. It does enter a date in the field, but it enters 1/1/0001 as the date.

Any more ideas? Thanks again.

Sign in to reply to this post

Ray BorduinWebAssist

Yeah I forgot to insert into the database you need to update it to 'Y-m-d' syntax... so the code would be:


<?php echo(date('Y-m-d',strtotime($_POST['yourfield'] . " +180 day"))); ?>

Sign in to reply to this post

Brad Lawryk

Thats the ticket! That worked perfectly! Thanks again ....

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...