operation with dates

------=_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:







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

<mailto:r.sanchez [at] ingenia-soluciones.com> =
r.gomez [at] ingenia-soluciones.com



Descripci=F3n: cid:image002.jpg [at] 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




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

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
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"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1"><meta name=3DGenerator content=3D"Microsoft Word =
12 (filtered medium)"><!--[if !mso]><style>v\:* =
{behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
..shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
[at] font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
[at] font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texto de globo Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EstiloCorreo17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.TextodegloboCar
{mso-style-name:"Texto de globo Car";
mso-style-priority:99;
mso-style-link:"Texto de globo";
font-family:"Tahoma","sans-serif";}
..MsoChpDefault
{mso-style-type:export-only;}
[at] page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DES link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
lang=3DEN-US>Hello! I’m trying to subtract two dates in my =
consult, but I don’t get it, I did:<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>mysql> select userID from user =
where (userPaymentDate - now()) < 365 ;<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>It didn’t work. Do you know =
how to do it? Thank you so much!<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US>Regards<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p><p =
class=3DMsoNormal><b><span lang=3DEN-US =
style=3D'font-size:10.0pt;color:#0070C0'>Roc=EDo G=F3mez =
Escribano<o:p></o:p></span></b></p><p class=3DMsoNormal><span =
lang=3DES-PE style=3D'font-size:10.0pt;color:#9D9D9D'><a =
href=3D"mailto:r.sanchez [at] ingenia-soluciones.com"><span lang=3DEN-US =
style=3D'color:blue'>r.gomez [at] ingenia-</span><span =
style=3D'color:blue'>soluciones.com</span></a><o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:blue'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:9.0pt;color:#9D9D9D'><img =
border=3D0 width=3D181 height=3D74 id=3D"Imagen_x0020_1" =
src=3D"cid:image001.jpg [at] 01CC10C6.BDE2D3F0" alt=3D"Descripci=F3n: =
cid:image002.jpg [at] 01CB8CB6.ADEBA830"></span><span =
style=3D'font-size:12.0pt;color:blue'><o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:10.0pt;color:#A6A6A6'>Pol=EDgono Campollano C/F, =
n=BA21T</span><span =
style=3D'font-size:10.0pt;color:blue'><o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'font-size:10.0pt;color:#9D9D9D'>02007 =
Albacete (Espa=F1a)<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-GB =
style=3D'font-size:10.0pt;color:#9D9D9D'>Tlf:967-504-513  Fax: =
967-504-513<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;color:#A6A6A6'><a =
href=3D"www.ingenia-soluciones.com" =
title=3D"blocked::www.ingenia-soluciones.com"><span lang=3DEN-GB =
style=3D'color:#9D9D9D'>www.ingenia-soluciones.com</span></a></span><span=
lang=3DEN-GB =
style=3D'font-size:10.0pt;color:#A6A6A6'><o:p></o:p></span></p><p =
class=3DMsoNormal><span =
lang=3DEN-US><o:p> </o:p></span></p></div></body></html>
------=_NextPart_001_0005_01CC10C6.BF0F6D10--

------=_NextPart_000_0004_01CC10C6.BF0F6D10--
Rocio Gomez Escribano [ Do, 12 Mai 2011 17:05 ] [ ID #2059400 ]

Re: operation with dates

--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 [at] 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 [at] ingenia-soluciones.com <r.sanchez [at] ingenia-soluciones.com>
>
>
>
> [image: Descripci=F3n: cid:image002.jpg [at] 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--
Andrew Moore [ Do, 12 Mai 2011 17:10 ] [ ID #2059401 ]

RE: operation with dates

I found it,



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


Thanks

Roc=EDo G=F3mez Escribano
r.gomez [at] 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 [at] gmail.com]
Enviado el: jueves, 12 de mayo de 2011 17:11
Para: Rocio Gomez Escribano
CC: mysql [at] 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 [at] 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 [at] ingenia-soluciones.com <r.sanchez [at] ingenia-soluciones.com>
>
>
>
> [image: Descripci=F3n: cid:image002.jpg [at] 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 [at] m.gmane.o rg
Rocio Gomez Escribano [ Do, 12 Mai 2011 17:10 ] [ ID #2059402 ]

Re: operation with dates

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 [at] 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 [at] m.gmane.org
Dan Nelson [ Do, 12 Mai 2011 20:06 ] [ ID #2059403 ]

Re: operation with dates

>>>> 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 [at] m.gmane.org
(Halász Sándor) hsv [ Fr, 13 Mai 2011 02:03 ] [ ID #2059450 ]

Re: operation with dates

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 [at] 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 [at] m.gmane.org
Dan Nelson [ Fr, 13 Mai 2011 16:46 ] [ ID #2059453 ]

Re: operation with dates

>>>> 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 [at] m.gmane.org
(Halász Sándor) hsv [ Fr, 13 Mai 2011 19:55 ] [ ID #2059512 ]
Datenbanken » gmane.comp.db.mysql.general » operation with dates

Vorheriges Thema: MySQL v5.5.12 on Mac OSX - Server won't start...
Nächstes Thema: URGENT: Change Default Location of where Database Files get written?