Breaking Down The Difference Between Two Dates In SQL Server To Their Constituent Parts

SQL Server No Comments »

I regularly have the need to break down a date in SQL Server. I might need to produce a report by hour or 15 minute intervals so I find the following bit of code useful. It is heavily commented to give you an idea of how it works.

-- Variables to hold the start and end dates and the difference between them.
DECLARE @Start datetime;
DECLARE @End datetime;
DECLARE @Diff datetime;

-- Set the start and end date then calculates the difference.
SET @Start = '2000-01-01';
SET	@End = GETDATE();
SET @Diff = @End - @Start;

SELECT @Start [StartDate]
,    @End [EndDate]

-- The number of years between the two dates.
,    DATEDIFF(yy, 0, @Diff) [Years]

-- Add the difference in years to the start date to remove years from the result.
,    DATEDIFF(dd, DATEADD(yy, DATEDIFF(yy, 0, @Diff), @Start), @End) [Days]

-- Use of the DATEPART function to break down the remainder of the difference.
,    DATEPART(hour, @Diff) [Hours]
,    DATEPART(minute, @Diff) [Minutes]
,    DATEPART(second, @Diff) [Seconds]
,    DATEPART(ms, @Diff) [Milliseconds];

This then produces the following result.

I hope somebody finds that useful.

Why I Dumb Down The Admin Account On New WordPress Installations

Web Development 1 Comment »

Quick links

What is the problem?

WordPress prides itself on its 5 minute install allowing you to essentially upload the core files, create a database and then run a script to join the two together. Easy. But secure it isn’t…

A hacker with limited knowledge of WordPress knows that the login screen is generally found at the following path of http://blog.domain/wp-login.php and also that WordPress by default sets up an admin account during the installation stage. You would hope the first thing the user then does is logs in with the auto-generated details and changes the password to something memorable and hard to guess right? You would have thought so.

Read the rest of this entry »

Using Amazon S3 To Backup My WordPress Blog

Web Development 1 Comment »

A couple of days ago I wrote a post on my blog about implementing a backup strategy for archiving the website files and database related to this blog. Although I was happy with the result and they do work well I was still a bit concerned because the files were still on the server which meant I had to manually retrieve them off the server to be sure of having a suitable backup should something happen to the server.

I decided to try out Amazon S3 which allows you to store files in “buckets” located in America and Ireland. Authentication is used to secure your data and it uses standards-based REST and SOAP interfaces to allow developers the ability to hook on to the service. They operate a “Pay For What You Use” pricing model of $0.15 a month per GB hosted which is about £0.09 a month. Currently all data transfer is free until 30th June 2010 but even after then it is only $0.10 a month per GB which is about £0.06 a month. The prices change after 50TB of data is being hosted but that is unlikely at present. If this trial is successful then I intend to roll it out across my other websites.

Read the rest of this entry »

Firefox Add-ons I Can't Live Without

Web Development No Comments »

I have used Mozilla Firefox for many years now when I have been developing websites and also for personal use too. It may not be the fastest browser around but I am willing to sacrifice speed for usability in this case as the add-ons available for Firefox are some of the best around. I am going to go through some of them and why I use them and hopefully help someone else to discover a useful add-on they might not have heard of before.

Read the rest of this entry »

Why I Chose To Get PRINCE2 Certified

Project Management 2 Comments »

PRINCE2 is a process driven project management framework that has 40 different activities organised into seven processes.

These processes are:

  1. Starting up a project
  2. Initiating a project
  3. Directing a project
  4. Controlling a stage
  5. Managing stage boundaries
  6. Closing a project
  7. Managing product delivery

Read the rest of this entry »

Rolling My Own WordPress Blog Backup Strategy

General 5 Comments »

I have been very complacent about implementing a backup strategy for my blog files but after reading about codinghorror.com and haacked.com amongst others recently falling foul to a hardware failure on the server that hosted their blogs and the struggles they had to try and retrieve their content again I realised that something needed to be done. In fact Phil Haack sums it up quite nicely in this tweet.

Read the rest of this entry »

Adding Tasks And Subtasks To A Plan In Microsoft Project 2010

Project Management 7 Comments »

First thing I did was downloaded the latest PRINCE2 2009 Process Model diagram which is available in PDF on the PRINCE2 website.

Next I loaded up Microsoft Project 2010 and entered the high level task I am going to use which in this case is the ‘Starting up a project’ stage.

Read the rest of this entry »

Microsoft Project 2010 Is The Most Interesting Release In Years

Project Management No Comments »

If you are a project manager dealing with any size of project then you will more than likely have come across Microsoft Project and quite possibly use it on a regular basis.

Recently Microsoft announced on their Project Team blog that the public beta of Project 2010 was available for download. They have also produced a website where they call this version of Project the most significant release in a decade.

Read the rest of this entry »

Hello world!

General No Comments »

Hello and welcome to my new blog. If you have got this page but you were expecting something else on my site then apologies it is unlikely the page exists anymore.

A short while ago I went to log in to my old blog to find that I couldn’t. After more investigation I found the database was corrupted so a fresh install was required.

I am not too upset by this because I let my old blog slip a bit but this time round things will be different. No really they will.

I hope you stick with me because I have a few interesting posts lined up. Save my RSS feed in your favourite news reader and it will be updated soon.

Cheers, Ian.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in