Jump to content

Holidays


samona

Recommended Posts

Hi,

 

I'm trying to create a query that will look back to a previous entry and retrieve the information on that record. 

 

I figured out how to do it when its Friday.

 

if (date('D') == "Mon")
{

$query = 'SELECT * FROM Table WHERE ((DATE_FORMAT(Table.Current_Date, \'%Y %m %d\')) = (DATE_FORMAT(NOW() - INTERVAL 3 DAY, \'%Y %m %d\'))) && (Type = \'type\')';
}

else
{
$query = 'SELECT * FROM Table WHERE ((DATE_FORMAT(Table.Current_Date, \'%Y %m %d\')) = (DATE_FORMAT(NOW() - INTERVAL 1 DAY, \'%Y %m %d\'))) && (Type = \'type\')';
}

 

However, if there is a holiday, the -3 days will not work since the last record could have been inserted 4 days ago or even 5 days ago. 

 

How would I solve this problem?

Link to comment
Share on other sites

Well, this "problem" is simply that you need to know what dates are holidays... do you have such a table?

 

As an aside, your code will be much easier to read (and write) if you have your $query variabled double-quoted.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.