Monday, September 27, 2010

Monday, September 20, 2010

Wednesday, September 15, 2010

DateDiff

Recently, I had to work out the number of months between two arbitrary dates. In C# this is a bit of a challenge, simply because DateTime.Subtract(DateTime) returns a TimeSpan, which does not have a Months property.

This is because TimeSpan doesn't know which months it would be referring to. Specifically, to know how many months there are in a date range you need to count each month index from date A to date B. Problem being, if you don't know those arbitrary dates - you only have a count of days - how many months does that range cover?

Example: How many months does 30 days represent? Answer: 1.

Wrong.

Why?... Because if we are talking about February, it's two months. If we're talking about August it's not a whole month.

The solution is to take into account the specific dates being used in the subtraction and count their months, unfortunately. Yeah, I don't want to write that code either.

However, for the C#'ers among us, there is a solution. VB has a DateDiff class which can do this for you. Just use the Microsoft.VisualBasic namespace and the static DateDiff method, as I found out here:
Here's a post about writing your own:

Friday, September 10, 2010

Wednesday, September 08, 2010

Tuesday, September 07, 2010

The Register: iPad Apps Galore

The Register has pulled together a collection of iPad apps for geeks, techies and web pros...

Monday, September 06, 2010

LINQ2SQL Transaction

A good thread to read on LINQ to SQL transactions, centred on commits and rollbacks:

Wednesday, September 01, 2010

Why Not? "Wave-Enabled" Google Email Server

I was thinking that it's a shame that Google didn’t take the Wave, build it into their email server and have just an option that let you “email in real time”, ie: any email on their system could be seen to be edited in real time (as wave showed) but in the gmail editor.

The major work would be in the server, so that it is still an email system, exchange compatible and all, but also makes this new function available. Hopefully, people would use it more and more as rapid email repliers discover they are responding quickly.

Perhaps Google could then market their own email server as “Wave-enabled, MS Exchange-compatible”.

So simple really – read this: