1 Use[Master]
2GO
3/** * * * object:userdefinedfunction [dbo]. [Dtgetxun] Script date:04/06/2016 17:41:12 * * * * **/
4 SETAnsi_nulls on
5GO
6SETQuoted_identifier on
7GO
8-- =============================================
9--Author: <Author,,Name>
Ten--Create Date: <create date,,>
One--Description: A string converted from a datetime type to a lent format
A -- =============================================
-CREATEFUNCTION[dbo].[Dtgetxun]
-(
the --ADD The Parameters for the function here
-@dtdatetime
-)
-RETURNSvarchar( -)
+ as
-BEGIN
+Declare@dtWithXunvarchar( -)
ADeclare@xun varchar( -)
atif( Day(@dt)between0 andTen)
-begin
-Set@xun='Early'
-End
-if( Day(@dt)between One and -)
-begin
inSet@xun='Mid'
- End
toif( Day(@dt)> -)
+begin
-Set@xun='Late'
theEnd
*
$Select@dtWithXun=cast( Year(@dt) asvarchar( -))+'years'+cast(Month(@dt) asvarchar( -))+'Month'+@xun
Panax Notoginsengreturn@dtWithXun
-
theEND
Get the current date