A table exists with id and datetime columns; I need to SELECT records from
the previous business day. I began with this:
SELECT id FROM table WHERE TO_DAYS(NOW()) - TO_DAYS(datetime) =1
But if NOW() is a Monday, it pulls records from Sunday (there are none since
records are inserted
.
- Original Message -
From: Stembridge, Michael [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Sent: Tuesday, March 22, 2005 4:30 PM
Subject: SELECT rows from the previous business day
A table exists with id and datetime columns; I need to SELECT records from
the previous business day
Stembridge, Michael [EMAIL PROTECTED] wrote on 03/22/2005 10:30:50
AM:
A table exists with id and datetime columns; I need to SELECT records
from
the previous business day. I began with this:
SELECT id FROM table WHERE TO_DAYS(NOW()) - TO_DAYS(datetime) =1
But if NOW() is
Michael,
Someone on the list recently dave this quickie formula for computing
the no. of biz days::
DATEDIFF(date2, date1) - (WEEK(date2) - WEEK(date1)) * 2
PB
-
Stembridge, Michael wrote:
A table exists with id and datetime columns; I need to SELECT records from
the previous
One problem with that formula is that it fails if you wrap around from one
year to the next. But as a quickie, it's good.
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
Peter Brawley [EMAIL PROTECTED] wrote on 03/22/2005 01:01:29
PM:
Michael,
Someone on the list