Saturday, October 10, 2009

MySQL Query to check if a birthday is upcoming in 7 days

Someone probably has done this before, but in case it hasn't been done, here's my query:

$result = mysql_query("SELECT FirstName, LastName, DATE_FORMAT(birthday, '%M %d') as bday, CONCAT(IF(MONTH(birthday)=1 AND MONTH(CURRENT_DATE())=12, YEAR(CURRENT_DATE())+1, YEAR(CURRENT_DATE())), DATE_FORMAT(birthday, '-%m-%d')) AS fakebirthday FROM birthdays WHERE CONCAT(IF(MONTH(birthday)=1 AND MONTH(CURRENT_DATE())=12, YEAR(CURRENT_DATE())+1, YEAR(CURRENT_DATE())), DATE_FORMAT(birthday, '-%m-%d')) BETWEEN CURRENT_DATE() AND DATE_ADD(CURRENT_DATE(), INTERVAL 7 DAY) ORDER BY fakebirthday;");

What it does (this is PHP code, but the stuff in double-quotes is the real meat.):

  1. birthday is stored in datetime format
  2. The SELECT AS is relatively straight-forward. I don't want to divulge age/years of this list, so I'm only reporting month and day (January 1) in the result
  3. I'm making a fakebirthday calculation in order to sort/Order by. Unfortunately, I can't use the fakebirthday in "WHERE" clause, so I repeated the calculation to do my "WHERE".
  4. The idea is to check for the next 7 days, and cheat by prepending *this* year on the birthday's month and day. Unfortunately, if this month is December (12) and the birthday is in January (1), this won't work, so add 1 to this year and prepend it to the January birthdates -- but only when running this in December.
  5. of course, check if it's between today and 7 days from today
  6. and sort by the "fake" birthday because it's easier to sort this way so that January comes after December


Oh, I know it's ugly code. It's probably slow, too. However, the idea is this should run once a day (once a week?) on fairly small amounts of data (office active employee records).

Friday, September 18, 2009

Smoothwall/Firewall check for spambot on lan

More or less, this is a placeholder until I get more information.

You have smoothwall or other linux based firewall proxy.
type this
tcpdump -qt port 25
on the proxy server.
ctrl-c to abort

Monday, August 31, 2009

Microsoft Outlook won't connect to Exchange Server

I was troubleshooting an issue where the Outlook client wouldn't connect to Exchange Server. It wasn't a ping issue (I could ping the server) and it wasn't domain resolution. I also could view the one user's Outlook Web Access Account. It simply wouldn't connect Outlook to Exchange, either hanging on profile creation, or giving an error on connect.

To fix this, I went to c:\documents and settings\username\local settings\application data\microsoft\outlook and added a new folder "old" and moved the stuff in outlook folder to "old" and tried again. This apparently cleaned itself up.

Sunday, August 30, 2009

Computer sluggish? Check your path

After decommissioning a server, it was found that certain machines were DOG slow. This apparently was because an app changed the PATH variable to point to a directory structure on the now defunct server. To fix this, the best way is to go to Windows System Properties, advanced, Environment variables, Path and remove the errant directory structure.

This may very well affect other pieces of software, such as your antivirus program on startup.

Thursday, August 27, 2009

Changing hard drives with Clonezilla

For whatever it's worth, System Restore on Vista didn't know the "new" c: drive that I upgraded to, and system restore failed.

Right-click My Computer, Properties.
System Protection (left side)
Uncheck anything said as (Missing) and make certain C: that is (Local) is checked, apply, (yes) ok.

Now System Restore functions properly. Also, you can use this to put System Restore on an optional other disk.

Monday, August 24, 2009

ComboFix fixes UACD.SYS

I love me some malwarebytes, but when it doesn't work ComboFix does. More info here: bleepingcomputer.com

Monday, August 3, 2009

Outlook quick-launch idea

Look, it's an idea. If someone else has it, this is notification that I haven't seen this implemented in this way before.

The implementation of the icon for Outlook 2007 is .. well, it's meh, ok?

Here's what I'd like to happen:

  1. Outlook that's minimized disappears from the taskbar, but can be re-opened from the status icon (by the clock)
  2. The Outlook status icon is a launching pad for what Outlook does, navigation/popup withOUT clicking:

    1. Inbox (New#)
    2. Calendar
    3. Tasks/Todo List
    4. Contacts


The idea is that you'd hover your mouse over the clock icon, and left-to-right above the icon, you'd have the above list a-d in a single horizontal row. Hovering over each of those would have a context-sensitive pop-up above that bar.
For Inbox, that would be a brief list of the 10 most recent emails: From, Subject, Date, first line of email.
For Calendar, that would be a month calendar over a scrollable list of itinerary (like Google Calendar's applet for iGoogle). Perhaps this may or may not be in combination with Tasks/Todo lists
For Contacts, that would be some painless way to get that phone number or write that email.

In addition, there should be some underlying "search everything for what I'm looking for".

Blog Archive