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 > choosing a date
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
choosing a date

Réponse
 
LinkBack Outils de la discussion
Vieux 03/01/2008, 20h04   #1
Sjef
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut choosing a date

Hi there,
I'm trying to create a sql statement in which a date is compared to another
date and depending on the comparison one is chosen.
such as:

if (date_add(cur_date(), interval 30 day) >=
'$thisDate','$this->date',date_add(cur_date(), interval 30 day)

So: if the current date plus 30 days is larger than thisDate then thisDate
is used, else the date plus 30 days is used.
But: it doesn't do what I expected it to do. Can anybody pint out the
reason. No error message or so ...

Thanks, Sjef


  Réponse avec citation
Vieux 03/01/2008, 20h29   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: choosing a date

Sjef wrote:
> Hi there,
> I'm trying to create a sql statement in which a date is compared to
> another date and depending on the comparison one is chosen.
> such as:
>
> if (date_add(cur_date(), interval 30 day) >=
> '$thisDate','$this->date',date_add(cur_date(), interval 30 day)
>
> So: if the current date plus 30 days is larger than thisDate then
> thisDate is used, else the date plus 30 days is used.
> But: it doesn't do what I expected it to do.

So what DOES it do?

> Can anybody pint out the
> reason. No error message or so ...

I can't pint it out, but I might be able to point it out.

I have to say that I'm amazed that you didn't get an error as there is a
closing bracket missing.



  Réponse avec citation
Vieux 03/01/2008, 21h18   #3
Sjef
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: choosing a date

The result was the date plus 30 days

"Paul Lautman" <paul.lautman@btinternet.com> schreef in bericht
news:5u4rclF1gg49eU1@mid.individual.net...
> Sjef wrote:
>> Hi there,
>> I'm trying to create a sql statement in which a date is compared to
>> another date and depending on the comparison one is chosen.
>> such as:
>>
>> if (date_add(cur_date(), interval 30 day) >=
>> '$thisDate','$this->date',date_add(cur_date(), interval 30 day)
>>
>> So: if the current date plus 30 days is larger than thisDate then
>> thisDate is used, else the date plus 30 days is used.
>> But: it doesn't do what I expected it to do.

> So what DOES it do?
>
>> Can anybody pint out the
>> reason. No error message or so ...

> I can't pint it out, but I might be able to point it out.
>
> I have to say that I'm amazed that you didn't get an error as there is a
> closing bracket missing.
>
>
>



  Réponse avec citation
Vieux 03/01/2008, 21h52   #4
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: choosing a date

Sjef wrote:
> "Paul Lautman" <paul.lautman@btinternet.com> schreef in bericht
> news:5u4rclF1gg49eU1@mid.individual.net...
>> Sjef wrote:
>>> Hi there,
>>> I'm trying to create a sql statement in which a date is compared to
>>> another date and depending on the comparison one is chosen.
>>> such as:
>>>
>>> if (date_add(cur_date(), interval 30 day) >=
>>> '$thisDate','$this->date',date_add(cur_date(), interval 30 day)
>>>
>>> So: if the current date plus 30 days is larger than thisDate then
>>> thisDate is used, else the date plus 30 days is used.
>>> But: it doesn't do what I expected it to do.

>> So what DOES it do?
>>
>>> Can anybody pint out the
>>> reason. No error message or so ...

>> I can't pint it out, but I might be able to point it out.
>>
>> I have to say that I'm amazed that you didn't get an error as there
>> is a closing bracket missing.

> The result was the date plus 30 days


Please do not top post (top posting fixed).

That is strange, I would have expected an error as there is a bracket
missing.

Can you echo the query as it would have been executed, so we can see what
'$thisDate' resolves to.

We can also understand how an if statement with an obvious syntax error
manages to run!



  Réponse avec citation
Vieux 04/01/2008, 17h58   #5
Sjef
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: choosing a date

OK, I found out that the function does not accept dates as 2008-1-10. When
the date is formatted as 2008-01-10 than the function works flawlessly. I
have finally used the LEAST function to choose between the two dates.
Thanks


"Sjef" <manuals-scripts@planet.nl> schreef in bericht
news:477d31c7$0$25490$ba620dc5@text.nova.planet.nl ...
> Hi there,
> I'm trying to create a sql statement in which a date is compared to
> another date and depending on the comparison one is chosen.
> such as:
>
> if (date_add(cur_date(), interval 30 day) >=
> '$thisDate','$this->date',date_add(cur_date(), interval 30 day)
>
> So: if the current date plus 30 days is larger than thisDate then thisDate
> is used, else the date plus 30 days is used.
> But: it doesn't do what I expected it to do. Can anybody pint out the
> reason. No error message or so ...
>
> Thanks, Sjef
>



  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 01h44.


É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,10736 seconds with 13 queries