Google Custom Search

Sunday, January 16, 2011

Get Details for Month for any given Date

The given script below will give details for a given date as below.

1. First Day of the month along with the Weekday
2. Weekday of the Given date
3. Last day of the month along with the Weekday

Script:

DECLARE @date DATETIME
SELECT @date = GETDATE() --INPUT YOUR DATE HERE
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@date)-1),@date),101) AS DateofMonth,datename(dw,CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@date)-1) ,@date),101)) as Week_Day,
'First Day of Month for Date Given' AS DayofMonth
UNION
SELECT CONVERT(VARCHAR(25),GETDATE(),101) AS DateofMonth, DAtename(dw,CONVERT(VARCHAR(25),GETDATE(),101)) as Week_Day,'Date Given' AS DayofMonth
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@date))),DATEADD(mm,1,@date)),101) ,DAtename(dw,CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@date))) ,DATEADD(mm,1,@date)),101)) as Week_Day,
'Last Day of Month for Date Given'

Result:

DateofMonth Week_Day DayofMonth
01/01/2011 Saturday First Day of Month for Date Given
01/16/2011 Sunday Date Given
01/31/2011 Monday Last Day of Month for Date Given

Back to Blogging

Life's changes happen so sooner than expected. It was the same period last year that I decided that I should minimize my blogging and professional network to spend more personal time as I anticipated busy personal and professional work.

It's this year that I know that I can spend few hours every week without affecting my personal or professional life, thanks to my understanding family and friends who would like to see me back to those good days. The difference was simple, attitude.

"I am too tired spending time learning, reading and writing. why not take sometime off and feel the personal life?, this was the one for last year and for this year it is "I have a understanding family, friends and people around me to help and keep me happy through my personal life, why not spend some time for the community?"

This difference made things easier for me to start writing back. You will see more and more blogging, discussions and posts from me. Keep me posted if you need anything specific.

At this moment, I would love to say sincere thanks to my understanding PARENTS and WIFE. Encouragement comes from nowhere, it comes from your heart, these are people who live there and that pushes me to move forward quicker.