IT Community - Software Programming, Web Development and Technical Support

Get Last Day of the Month Function

This is a discussion on Get Last Day of the Month Function within the Database Support forums, part of the Web Development category; How to Get Last Day of the Month Function in SQL Server CREATE FUNCTION [dbo].[ufn_GetLastDayOfMonth] ( @pInputDate DATETIME ) RETURNS DATETIME ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-21-2007, 08:40 PM
srikumar_l srikumar_l is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 196
srikumar_l is on a distinguished road
Default Get Last Day of the Month Function

How to Get Last Day of the Month Function in SQL Server

CREATE FUNCTION [dbo].[ufn_GetLastDayOfMonth]
( @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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of days in a month (or last day of a month) itbarota HTML, CSS and Javascript Coding Techniques 2 04-28-2008 08:47 PM
Find the last day of the month for any given month. itbarota HTML, CSS and Javascript Coding Techniques 1 03-17-2008 08:56 PM
Calculate how many hours per each month itbarota HTML, CSS and Javascript Coding Techniques 1 02-25-2008 09:23 PM
Get First Day of the Month Function srikumar_l Database Support 0 12-21-2007 08:37 PM
Diff inline function and ordinary function vigneshgets C and C++ Programming 1 05-24-2007 11:34 AM


All times are GMT -7. The time now is 07:02 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0