I have been writing SQL stored procedures for a while now, but whilst I am testing out the code before creating the stored procedure, I always found declaring and setting a date to be a pain!
So I decided to create a function that you enter the year month day and it converts this to a date.
So here it is.... The code
CREATE FUNCTION [dbo].[fn_BuildDate] (@Year int, @Month int, @Day int)
DECLARE @vInputDate DATETIME
SET @vInputDate = dateadd(day, @Day - 1, dateadd(month, @Month - 1, dateadd(year, @Year-1900, 0)))
Using the code
To use the function is nice and easy in comparison to normally casting a date
DECLARE @StartDate Date
SET @StartDate = dbo.fn_BuildDate(2012,11,23)
Hope it helps someone else!
My first memories of programming were back in the days of Amstrad 464+, and we used to get a magazine called "Amstrad Action", every issue had some games or programs you could code into the computer and I used to love doing this.
I remember watching "War Games" at the same time as typing in the code to a small game on the computer, and thought it would be amazing to be able to connect the computer to the telephone!
In 2000, I started a computing A Level, part of the course was Delphi Programming, and I remember writing an application to display train time tables and ticket costs, and creating a manual of how to use it, and the lecturer said to me back then I would have a career as a Manual writer or a programmer. (I chose Programmer)
The programming lecturer was a lively, wacky lecturer, and that made it entertaining.
I then went back to night school in 2006 and learnt VB.NET.
This lecturer (at a different college, in a different country was also quite wacky and lively (seemed to be a common occurrence))
During the second year at night school my employer asked if I could put together a quotation application, I said I was up for it and the MD and I spent a day or two a week looking into the calculations, and after a few months we had created a quotation application that they still use to this day!
I created 4 more applications before joining my previous employer in 2008.
At my previous employment I created Mobile Software for Windows Mobile 6.1, Integrated with Sage Line 50, Exchequer, created ASP.NET websites, SSRS Reports for Customers and Internal use, created the UI for the new Scheduling application, and more.
Now working for Gemba Solutions Ltd as a Product Development Support Engineer.