operation with dates

operation with dates

am 12.05.2011 17:05:06 von Rocio Gomez Escribano

------=_NextPart_000_0004_01CC10C6.BF0F6D10
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0005_01CC10C6.BF0F6D10"


------=_NextPart_001_0005_01CC10C6.BF0F6D10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello! I=92m trying to subtract two dates in my consult, but I don=92t =
get it, I
did:

=20

=20

=20

mysql> select userID from user where (userPaymentDate - now()) < 365 ;

=20

=20

It didn=92t work. Do you know how to do it? Thank you so much!

=20

Regards

=20

Roc=EDo G=F3mez Escribano

=
r.gomez@ingenia-soluciones.com

=20

Descripci=F3n: cid:image002.jpg@01CB8CB6.ADEBA830

Pol=EDgono Campollano C/F, n=BA21T

02007 Albacete (Espa=F1a)

Tlf:967-504-513 Fax: 967-504-513

www.ingenia-soluciones.com

=20


------=_NextPart_001_0005_01CC10C6.BF0F6D10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"> http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1"> 12 (filtered medium)"> vlink=3Dpurple>

lang=3DEN-US>Hello! I’m trying to subtract two dates in my =
consult, but I don’t get it, I did:

class=3DMsoNormal> 

class=3DMsoNormal> 

class=3DMsoNormal> 

class=3DMsoNormal>mysql> select userID from user =
where (userPaymentDate - now()) < 365 ;

class=3DMsoNormal> 

class=3DMsoNormal> 

class=3DMsoNormal>It didn’t work. Do you know =
how to do it? Thank you so much!

class=3DMsoNormal> 

class=3DMsoNormal>Regards

class=3DMsoNormal> 

class=3DMsoNormal> style=3D'font-size:10.0pt;color:#0070C0'>Roc=EDo G=F3mez =
Escribano

lang=3DES-PE style=3D'font-size:10.0pt;color:#9D9D9D'> href=3D"mailto:r.sanchez@ingenia-soluciones.com"> style=3D'color:blue'>r.gomez@ingenia- style=3D'color:blue'>soluciones.com

class=3DMsoNormal> style=3D'color:blue'> 

class=3DMsoNormal> border=3D0 width=3D181 height=3D74 id=3D"Imagen_x0020_1" =
src=3D"cid:image001.jpg@01CC10C6.BDE2D3F0" alt=3D"Descripci=F3n: =
cid:image002.jpg@01CB8CB6.ADEBA830">
style=3D'font-size:12.0pt;color:blue'>

class=3DMsoNormal> style=3D'font-size:10.0pt;color:#A6A6A6'>Pol=EDgono Campollano C/F, =
n=BA21T
style=3D'font-size:10.0pt;color:blue'>

class=3DMsoNormal>02007 =
Albacete (Espa=F1a)

lang=3DEN-GB =
style=3D'font-size:10.0pt;color:#9D9D9D'>Tlf:967-504-513  Fax: =
967-504-513

style=3D'font-size:10.0pt;color:#A6A6A6'> href=3D"www.ingenia-soluciones.com" =
title=3D"blocked::www.ingenia-soluciones.com"> style=3D'color:#9D9D9D'>www.ingenia-soluciones.com
lang=3DEN-GB =
style=3D'font-size:10.0pt;color:#A6A6A6'>

class=3DMsoNormal> lang=3DEN-US> 


------=_NextPart_001_0005_01CC10C6.BF0F6D10--

------=_NextPart_000_0004_01CC10C6.BF0F6D10--

RE: operation with dates

am 12.05.2011 17:10:15 von Rocio Gomez Escribano

I found it,=20



mysql> select userID from user where datediff(now(), userPaymentDate)< =
365;


Thanks

Roc=EDo G=F3mez Escribano
r.gomez@ingenia-soluciones.com


Pol=EDgono Campollano C/F, n=BA21T
02007 Albacete (Espa=F1a)
Tlf:967-504-513=A0 Fax: 967-504-513
www.ingenia-soluciones.com

-----Mensaje original-----
De: Andrew Moore [mailto:eroomydna@gmail.com]=20
Enviado el: jueves, 12 de mayo de 2011 17:11
Para: Rocio Gomez Escribano
CC: mysql@lists.mysql.com
Asunto: Re: operation with dates

Rocio,

there are specific date functions that you need to learn to allow you to
complete this kind of query. Please check out the MySQL documentation =
for
this.

HTH

Andy

On Thu, May 12, 2011 at 4:05 PM, Rocio Gomez Escribano <
r.gomez@ingenia-soluciones.com> wrote:

> Hello! I=92m trying to subtract two dates in my consult, but I don=92t =
get it,
> I did:
>
>
>
>
>
>
>
> mysql> select userID from user where (userPaymentDate - now()) < 365 ;
>
>
>
>
>
> It didn=92t work. Do you know how to do it? Thank you so much!
>
>
>
> Regards
>
>
>
> *Roc=EDo G=F3mez Escribano*
>
> r.gomez@ingenia-soluciones.com
>
>
>
> [image: Descripci=F3n: cid:image002.jpg@01CB8CB6.ADEBA830]
>
> Pol=EDgono Campollano C/F, n=BA21T
>
> 02007 Albacete (Espa=F1a)
>
> Tlf:967-504-513 Fax: 967-504-513
>
> www.ingenia-soluciones.com
>
>
>



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: operation with dates

am 12.05.2011 17:10:39 von Andrew Moore

--20cf305b091a921f3904a3159748
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Rocio,

there are specific date functions that you need to learn to allow you to
complete this kind of query. Please check out the MySQL documentation for
this.

HTH

Andy

On Thu, May 12, 2011 at 4:05 PM, Rocio Gomez Escribano <
r.gomez@ingenia-soluciones.com> wrote:

> Hello! I=92m trying to subtract two dates in my consult, but I don=92t ge=
t it,
> I did:
>
>
>
>
>
>
>
> mysql> select userID from user where (userPaymentDate - now()) < 365 ;
>
>
>
>
>
> It didn=92t work. Do you know how to do it? Thank you so much!
>
>
>
> Regards
>
>
>
> *Roc=EDo G=F3mez Escribano*
>
> r.gomez@ingenia-soluciones.com
>
>
>
> [image: Descripci=F3n: cid:image002.jpg@01CB8CB6.ADEBA830]
>
> Pol=EDgono Campollano C/F, n=BA21T
>
> 02007 Albacete (Espa=F1a)
>
> Tlf:967-504-513 Fax: 967-504-513
>
> www.ingenia-soluciones.com
>
>
>

--20cf305b091a921f3904a3159748--

Re: operation with dates

am 12.05.2011 20:06:32 von Dan Nelson

In the last episode (May 12), Rocio Gomez Escribano said:
> I found it,
>
> mysql> select userID from user where datediff(now(), userPaymentDate)< 365;

This can be made more readable by using mysql's INTERVAL syntax. It can
also be made more efficient by moving userPaymentDate out of the function,
so if you have an index on that column mysql can use it:

select userID from user where userPaymentDate > (now() - interval 1 year)

--
Dan Nelson
dnelson@allantgroup.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: operation with dates

am 13.05.2011 02:03:18 von (Halász Sándor) hsv

>>>> 2011/05/12 13:06 -0500, Dan Nelson >>>>
In the last episode (May 12), Rocio Gomez Escribano said:
> I found it,
>
> mysql> select userID from user where datediff(now(), userPaymentDate)< 365;

This can be made more readable by using mysql's INTERVAL syntax.
<<<<<<<<
And less portable....


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: operation with dates

am 13.05.2011 16:46:45 von Dan Nelson

In the last episode (May 12), Halßsz Sßndor said:
> >>>> 2011/05/12 13:06 -0500, Dan Nelson >>>>
> In the last episode (May 12), Rocio Gomez Escribano said:
> > I found it,
> >
> > mysql> select userID from user where datediff(now(), userPaymentDate)< 365;
>
> This can be made more readable by using mysql's INTERVAL syntax.
> <<<<<<<<
> And less portable....

Datediff isn't portable, either :)

--
Dan Nelson
dnelson@allantgroup.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: operation with dates

am 13.05.2011 19:55:02 von (Halász Sándor) hsv

>>>> 2011/05/13 09:46 -0500, Dan Nelson >>>>
Datediff isn't portable, either :)
<<<<<<<<
What of the date arithmetic is? I looked at it, and saw beside much that it was MySQL extension. But at least a function of fixed arguments looks like any other function; there is hope of writing one. The INTERVAL form is also a (in syntax) different form.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org