RE: [PHP-DB] Date math functions...
| From: | SBCSI) | Date: | Wed, 15 Jan 2003 16:51:01 +0000 |
| Subject: | RE: [PHP-DB] Date math functions... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24874@lists.php.net to get a copy of this message | ||
Thanks. I was noticing that it was not working. Let me give this a
try and see how things go.
-----Original Message-----
From: 1LT John W. Holmes [mailto:holmes072000@charter.net]
Sent: Wednesday, January 15, 2003 10:32 AM
To: 1LT John W. Holmes; NIPP, SCOTT V (SBCSI); php-db@lists.php.net
Subject: Re: [PHP-DB] Date math functions...
> [snip]
> > if ($dateDiff == 3) {
> > mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> > said='$said'") or die(mysql_error());
> > mysql("$DBName","INSERT INTO Log VALUES('DATE_ADD($StopDate,
> > INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')") or
> > die(mysql_error());
> >
> > My big question is about using the "DATE_ADD" MySQL function inside
> > the INSERT statement. Is this allowed? If it is allowed, is it a bad
> idea
> > for some reason? Is there a better way of doing this? Thanks in
advance.
>
> Sure, that's allowed. You have $StopDate in PHP, so you could do it with
> some math in PHP, also, but then you'd have to worry about the end of
> months, years, etc, whereas DATE_ADD will do this for you.
>
> ---John Holmes...
Wait... just noticed your syntax error. Don't enclose the function in single
quotes, otherwise you're trying to insert a string.
Should be:
... VALUES (DATE_ADD($StopDate,INTERVAL 1 DAY), ...
---John Holmes...