SQLServer Custom Function --FnsumoftWotime

xiaoxiao2021-03-05  19

/ ************************************************** ************

** file: fnsumoftwotime.sql

** Name: FNSumoftWotime

** DESCRIPTION: Two "hours: minute: second" time comes and

The input parameters must be represented in a 24-hour format and cannot be "24:00:00"

** Return VALUES: VARCHAR (20)

** Parameters: @ dtmstart, @ dtmend

** Author: 毅翔 (MyGodness)

** Date: 2005-4-6

** Use method: select dbo.fnsumoftwotime ('9:00:00', '13:15:22')

*********************************************************** *********** /

Create Function FnsumoftWotime (@a varchar (8), @ b varchar (8))

Returns varchar (20)

AS

Begin

Declare @sum datetime

SELECT @ Sum = Convert (DateTime, @ a) Convert (DateTime, @ b)

RETURN CAST (CAST (DAY (@SUM) -1 AS INT * 24 DatePart (HH, @ SUM) AS VARCHAR) ':' Cast (DatePart (n, @ Sum) AS VARCHAR) ':' Cast (datepart (s, @ SUM) as varchar)

End

转载请注明原文地址:https://www.9cbs.com/read-39200.html

New Post(0)