MySQL Date Calculation

software development

#1

Hi, I’m trying to calculate a date in a mysql query based on an interval.

Here’s how it works…I have a variable with a MySQL formatted date (ie, 2004-08-15) as the start date. Then I want to calculate the interval from that date using a column in my table.

Here’s the example query, MySQL says there’s a syntax error, but I can’t figure it out.

$start_date = date I’m passing in
mstart = int column containing the number of days I need from the start date.

fstart = the new date calculated from $start_date + mstart

select mtype, mid, add_date(’$start_date’,INTERVAL mstart DAY) as fstart, mstart from milestone_master order by mstart, mtype

Any help is appreciated. :slight_smile:


#2

date_add, not add_date.

nate.