Solved

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

Posted on 2007-11-15
2
1,280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

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

Author Comment

by:Xavior2K3
ID: 20292390
Thanks :)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

627 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