Solved

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

Posted on 2007-11-15
2
1,267 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determining creation & modification dates on MySQL tables 4 39
Why do people dis php? 5 50
PHP AJAX JSON 2 61
Curl & PHP Command Help 4 23
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 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