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 !






Function to Format Date


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

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



The code sample combines built in sql functions - YEAR(), MONTH() and DAY() - to format a given date as YYYY/MM/DD .

Example: output will be of the form 2008/7/01

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

RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' +
CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/' +
CAST(DAY(@pInputDate) AS VARCHAR(2)) AS DATETIME)

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 to format date  .  Function to format date  .  Format date  .  

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 Count Number of Days in a Month
Previous Resource: Last Day of the Month
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