Calculating time difference in months as a decimal number

October 8th, 2008

There’s a number of functions out there for calculating the length of time in months but they only provide integer results. MySQL can do it too, for instance. But what if you need to get a precise number?

2008-11-15 minus 2008-10-01 can’t be one if you’re calculating rent. It must be 1.466…

Read the rest of this entry »

Absolute positioning in HTML e-mails for Outlook 2007

October 2nd, 2008

I couldn’t possibly explain my frustration from Microsoft switching Outlook’s rendering engine to Word so I better not even try. Instead, I’m going to tell you how to make Outlook/Word position elements absolutely.

The idea originally came from doublethink (written in Czech) who made a text field in Word, saved it as HTML and then dug through the mess to extract the essence. I just went a step further and did the same for images as well.
Read the rest of this entry »

processing IMAP folder on a regular basis

April 13th, 2008

When you need to check a mailbox on a regular basis and process messages that has arrived since your last check you may find that some messages were somehow skipped.

Read the rest of this entry »

How to deal with IMMUTABLE error in indexes that work with timestamps

March 19th, 2008

Say that in an older version of PostgreSQL you had an index like this:

  1. span class=”st0″>’day’

and now after upgrading to 8.1+ you’re getting:
ERROR: functions in index expression must be marked IMMUTABLE

Read the rest of this entry »

How to concatenate two object attributes and assign the result to a variable

March 4th, 2008

All right, this is really no rocket science it’s just something I needed and took me some time to figure out.

  1. "fullName""`$human->first` `$human->last`"}

or more robust version:

  1. "fullName"}
  2. {$human->first} {$human->last}
  3.