Solved

Using Date Functions (date_add, date_sub) With Fields Instead of Constant Values

Posted on 2007-11-15
2
1,258 Views
Last Modified: 2013-12-13
Hi,

I want to subtract a number of days from a date. Both the date and the number of days are stored in a record but I cant figure out how to use the DATE_ADD and DATE_SUB functions using fields and not constant values. I basically need:

   DATE_SUB(table.date_field, INTERVAL table.number_of_days DAY)

But this doesn't work. How can this be done?

Thanks,

Michael
0
Comment
Question by:Xavior2K3
2 Comments
 
LVL 20

Accepted Solution

by:
steelseth12 earned 250 total points
Comment Utility
DATE_SUB(table.date_field, INTERVAL CONCAT ( table.number_of_days, ' DAY'))
0
 
LVL 1

Author Comment

by:Xavior2K3
Comment Utility
Thanks :)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now