C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Last Day of the Month


Posted Date: 24 Apr 2008    Resource Type: Code Snippets    Category: Date & Time

Posted By: @@@ Hyderabadi Biryani @@@       Member Level: Diamond
Rating:     Points: 3



The code sample is a sql function that computes the last day of a given month. The input is a month and the year. Other inputs are normally ignored.

The output to this code is the last day of the month given in the input.

Example: last of the July,2008 is Thursday, 31 2008.


CREATE FUNCTION [dbo].[fn_LastDayOfMonth] ( @pInputDate DATETIME )
RETURNS DATETIME
BEGIN

DECLARE @vOutputDate DATETIME

SET @vOutputDate = CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' +
CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/01'
SET @vOutputDate = DATEADD(DD, -1, DATEADD(M, 1, @vOutputDate))

RETURN @vOutputDate

END
GO





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sql function for last day of a month  .  Last day of a month  .  Last day of a given month  .  Code for last day of a month  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Function to Format Date
Previous Resource: Sql Function for Finding First Day of a Quarter
Return to Discussion Resource Index
Post New Resource
Category: Date & Time


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use