Thanks for your help in the past, and this forum is great.
I have a question about dates, and in searching, there are huge amounts of results, but very hard to narrow it down to exactly what I'm asking.
In using PHP, I have some variables pulled from mysql databases (in the date format, no time) such as:
$a = "2009-03-31";
how would I, within php, subtract 28 days and get
$b = "2009-03-03"; (with a rollover if it goes below the first of the month)
the same calendar day of the previous month:
$b = "2009-02-31";
(which doesn't exist of course but hopefully a mysql query could use that in a date range anyway and create a report without an error)
Also for example get the start of the previous month:
$b = "2009-02-01";
or change the year
Is there a simple way, at least for the first task (subtract days or 1 calendar month) without writing a script to parse the string and do it the hard way?
Also, say I have
$a = "2009-03-09"; and
$c = "2009-01-17";
How could I tell the actual number of calendar days between them, where it would check for leap year, etc. ?
These would be used in queries such as:
mysql_query("SELECT * from $vtable WHERE (trxdate <= '$a') and (trxdate >= '$b' and (other_conditions, etc.) " );