anniversary selects

anniversary selects

am 27.12.2009 03:47:05 von Noel Butler

--=-D95c/upDG37wP0BztV6i
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,
Hope we all had a great Christmas!

I am trying to run a query that selects a member every 365 days so we
can send them a domain reminder.
For my test (because i'm too lazy to count out someone with hundreds of
days :) ) I am using a known member at around 27/28 days

Now if I use this if finds the member, it doesn't find them if I go
under to say 27 days, I've used the DATE_SUB many times before, but
never for an exact match.

SELECT * FROM `member` WHERE AddedOn>=DATE_SUB(CURDATE(), INTERVAL 28
DAY)

Now trying to get an exact match, fails.
SELECT * FROM `member` WHERE AddedOn=DATE_SUB(CURDATE(), INTERVAL 28
DAY)

Also tried one by one up to 30 and down to 25 days,

Would someone please mind slapping me a good one reminding me what I've
done wrong :)
I thought CURDATE ignored the hours/mins/secs etc, but it seems it does
not?

Thanks
Noel


--=-D95c/upDG37wP0BztV6i--

RE: anniversary selects

am 28.12.2009 23:53:29 von Daevid Vincent

Perhaps the examples here would help you:
http://dev.mysql.com/doc/refman/5.0/en/date-calculations.htm l

> -----Original Message-----
> From: Noel Butler [mailto:noel.butler@ausics.net]
> Sent: Saturday, December 26, 2009 6:47 PM
> To: mysql@lists.mysql.com
> Subject: anniversary selects
>
> Hi,
> Hope we all had a great Christmas!
>
> I am trying to run a query that selects a member every 365 days so we
> can send them a domain reminder.
> For my test (because i'm too lazy to count out someone with
> hundreds of
> days :) ) I am using a known member at around 27/28 days
>
> Now if I use this if finds the member, it doesn't find them if I go
> under to say 27 days, I've used the DATE_SUB many times before, but
> never for an exact match.
>
> SELECT * FROM `member` WHERE AddedOn>=DATE_SUB(CURDATE(), INTERVAL 28
> DAY)
>
> Now trying to get an exact match, fails.
> SELECT * FROM `member` WHERE AddedOn=DATE_SUB(CURDATE(), INTERVAL 28
> DAY)
>
> Also tried one by one up to 30 and down to 25 days,
>
> Would someone please mind slapping me a good one reminding me
> what I've
> done wrong :)
> I thought CURDATE ignored the hours/mins/secs etc, but it
> seems it does
> not?
>
> Thanks
> Noel
>
>


--
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: anniversary selects

am 29.12.2009 05:57:41 von Noel Butler

--=-CbyO19SA5RDUXNNPLqB8
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Thanks, that's exactly what I was after.

On Mon, 2009-12-28 at 14:53 -0800, Daevid Vincent wrote:

> Perhaps the examples here would help you:
> http://dev.mysql.com/doc/refman/5.0/en/date-calculations.htm l
>
> > -----Original Message-----
> > From: Noel Butler [mailto:noel.butler@ausics.net]
> > Sent: Saturday, December 26, 2009 6:47 PM
> > To: mysql@lists.mysql.com
> > Subject: anniversary selects
> >
> > Hi,
> > Hope we all had a great Christmas!
> >
> > I am trying to run a query that selects a member every 365 days so we
> > can send them a domain reminder.
> > For my test (because i'm too lazy to count out someone with
> > hundreds of
> > days :) ) I am using a known member at around 27/28 days
> >
> > Now if I use this if finds the member, it doesn't find them if I go
> > under to say 27 days, I've used the DATE_SUB many times before, but
> > never for an exact match.
> >
> > SELECT * FROM `member` WHERE AddedOn>=DATE_SUB(CURDATE(), INTERVAL 28
> > DAY)
> >
> > Now trying to get an exact match, fails.
> > SELECT * FROM `member` WHERE AddedOn=DATE_SUB(CURDATE(), INTERVAL 28
> > DAY)
> >
> > Also tried one by one up to 30 and down to 25 days,
> >
> > Would someone please mind slapping me a good one reminding me
> > what I've
> > done wrong :)
> > I thought CURDATE ignored the hours/mins/secs etc, but it
> > seems it does
> > not?
> >
> > Thanks
> > Noel
> >
> >



--=-CbyO19SA5RDUXNNPLqB8--