?
Solved

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

Posted on 2007-11-15
2
Medium Priority
?
1,287 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 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

719 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