tags:

views:

253

answers:

1

Hi, I've been stuck with this issue for days, which is something like calculating the numbers of weeks that lies between two days, for example:

Select @Days = (datediff( week, @pdtFromDate, @pdtToDate) - 1) * 5

This returns the output as 257.

I need to convert this script into MySQL.

Any suggestions?

+1  A: 
DATEDIFF(@date1, @date2)/7

That returns a fraction which I'm guessing you'll want to round in some way with CEIL(), ROUND() or FLOOR()

My test example with two defined dates:

SELECT FLOOR(DATEDIFF(DATE(20090215), DATE(20090101))/7);
James C