PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Alternative to DATEDIFF in MySQL version 4.0
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Alternative to DATEDIFF in MySQL version 4.0

Réponse
 
LinkBack Outils de la discussion
Vieux 07/01/2008, 01h46   #1
Adrienne Boswell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Alternative to DATEDIFF in MySQL version 4.0

The host server I am using is MySQL version 4.0.27-standard, which does not
have DATEDIFF. I am asking the host to upgrade, but in the meantime, I
still need to get my query to work:

SELECT fields FROM table WHERE DATEDIFF(YYYY-MM-DD,NOW())>= 0

Are there alternatives? Please advise.

Thanks in advance.
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

  Réponse avec citation
Vieux 07/01/2008, 03h10   #2
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

On Mon, 07 Jan 2008 01:46:35 GMT, Adrienne Boswell wrote:
> The host server I am using is MySQL version 4.0.27-standard, which does not
> have DATEDIFF. I am asking the host to upgrade, but in the meantime, I
> still need to get my query to work:
>
> SELECT fields FROM table WHERE DATEDIFF(YYYY-MM-DD,NOW())>= 0
>
> Are there alternatives? Please advise.
>
> Thanks in advance.


-- Not tested, but should give you the idea
SELECT fields FROM table
WHERE DATE_ADD(mydatecol, INTERVAL 1 MONTH) >= NOW();

gets you all the records in the past month.

http://dev.mysql.com/doc/refman/4.1/...functions.html

Just watch the version numbers when features were added and you'll be
fine.

--
Because of the diverse conditions of humans, it happens that some acts are
virtuous to some people, as appropriate and suitable to them, while the same
acts are immoral for others, as inappropriate to them.
-- Saint Thomas Aquinas
  Réponse avec citation
Vieux 07/01/2008, 15h23   #3
Adrienne Boswell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

Gazing into my crystal ball I observed "Peter H. Coffin"
<hellsop@ninehells.com> writing in
news:slrnfo361n.ih0.hellsop@abyss.ninehells.com:

> On Mon, 07 Jan 2008 01:46:35 GMT, Adrienne Boswell wrote:
>> The host server I am using is MySQL version 4.0.27-standard, which
>> does not have DATEDIFF. I am asking the host to upgrade, but in the
>> meantime, I still need to get my query to work:
>>
>> SELECT fields FROM table WHERE DATEDIFF(YYYY-MM-DD,NOW())>= 0
>>
>> Are there alternatives? Please advise.
>>
>> Thanks in advance.

>
> -- Not tested, but should give you the idea
> SELECT fields FROM table
> WHERE DATE_ADD(mydatecol, INTERVAL 1 MONTH) >= NOW();
>
> gets you all the records in the past month.


Yup, works fine for February on, but no joy for anything in January.

>
> http://dev.mysql.com/doc/refman/4.1/...functions.html
>
> Just watch the version numbers when features were added and you'll be
> fine.
>




--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

  Réponse avec citation
Vieux 07/01/2008, 15h35   #4
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

Adrienne Boswell wrote:
> Gazing into my crystal ball I observed "Peter H. Coffin"
> <hellsop@ninehells.com> writing in
> news:slrnfo361n.ih0.hellsop@abyss.ninehells.com:
>
>> On Mon, 07 Jan 2008 01:46:35 GMT, Adrienne Boswell wrote:
>>> The host server I am using is MySQL version 4.0.27-standard, which
>>> does not have DATEDIFF. I am asking the host to upgrade, but in the
>>> meantime, I still need to get my query to work:
>>>
>>> SELECT fields FROM table WHERE DATEDIFF(YYYY-MM-DD,NOW())>= 0
>>>
>>> Are there alternatives? Please advise.
>>>
>>> Thanks in advance.

>>
>> -- Not tested, but should give you the idea
>> SELECT fields FROM table
>> WHERE DATE_ADD(mydatecol, INTERVAL 1 MONTH) >= NOW();
>>
>> gets you all the records in the past month.

>
> Yup, works fine for February on, but no joy for anything in January.
>
>>
>> http://dev.mysql.com/doc/refman/4.1/...functions.html
>>
>> Just watch the version numbers when features were added and you'll be
>> fine.


Can you post exactly what you are trying to do?
DATEDIFF(YYYY-MM-DD,NOW())
is not a valid expression.
Assuming that your YYYY-MM-DD actually refers to a date ot datetime column,
what is wrong with just doing
YYYY-MM-DD >= NOW()


  Réponse avec citation
Vieux 07/01/2008, 15h50   #5
Adrienne Boswell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

Gazing into my crystal ball I observed "Paul Lautman"
<paul.lautman@btinternet.com> writing in
news:5uev6uF1hpothU1@mid.individual.net:

> Adrienne Boswell wrote:
>> Gazing into my crystal ball I observed "Peter H. Coffin"
>> <hellsop@ninehells.com> writing in
>> news:slrnfo361n.ih0.hellsop@abyss.ninehells.com:
>>
>>> On Mon, 07 Jan 2008 01:46:35 GMT, Adrienne Boswell wrote:
>>>> The host server I am using is MySQL version 4.0.27-standard, which
>>>> does not have DATEDIFF. I am asking the host to upgrade, but in
>>>> the meantime, I still need to get my query to work:
>>>>
>>>> SELECT fields FROM table WHERE DATEDIFF(YYYY-MM-DD,NOW())>= 0
>>>>
>>>> Are there alternatives? Please advise.
>>>>
>>>> Thanks in advance.
>>>
>>> -- Not tested, but should give you the idea
>>> SELECT fields FROM table
>>> WHERE DATE_ADD(mydatecol, INTERVAL 1 MONTH) >= NOW();
>>>
>>> gets you all the records in the past month.

>>
>> Yup, works fine for February on, but no joy for anything in January.
>>
>>>
>>> http://dev.mysql.com/doc/refman/4.1/...functions.html
>>>
>>> Just watch the version numbers when features were added and you'll
>>> be fine.

>
> Can you post exactly what you are trying to do?
> DATEDIFF(YYYY-MM-DD,NOW())
> is not a valid expression.
> Assuming that your YYYY-MM-DD actually refers to a date ot datetime
> column, what is wrong with just doing
> YYYY-MM-DD >= NOW()
>
>
>


Wow! It worked. I must have had something wrong in my original query.
Thank you for hitting me on the head with the obvious!

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

  Réponse avec citation
Vieux 07/01/2008, 15h51   #6
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

Adrienne Boswell wrote:
>
> Wow! It worked. I must have had something wrong in my original
> query. Thank you for hitting me on the head with the obvious!


Hope it didn't hurt too much!




  Réponse avec citation
Vieux 08/01/2008, 02h50   #7
Adrienne Boswell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Alternative to DATEDIFF in MySQL version 4.0

Gazing into my crystal ball I observed "Paul Lautman"
<paul.lautman@btinternet.com> writing in news:5uf044F1hf9t2U1
@mid.individual.net:

> Adrienne Boswell wrote:
>>
>> Wow! It worked. I must have had something wrong in my original
>> query. Thank you for hitting me on the head with the obvious!

>
> Hope it didn't hurt too much!
>


Nah, it only hurts in public ... <science fiction style music>You can't
feel anything in Usenet</science fiction style music>



--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16945 seconds with 15 queries