Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SQL Function for Get Date Only

How to return the date part only from a SQL Server datetime


Create FUNCTION [dbo].[ufn_GetDateOnly] ( @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


This post first appeared on Asp.netSourceCodes, please read the originial post: here

Share the post

SQL Function for Get Date Only

×

Subscribe to Asp.netsourcecodes

Get updates delivered right to your inbox!

Thank you for your subscription

×