Moin,
habe ne Funktion gefunden
SQL-Code:
CREATE FUNCTION FN_DATETIME_AS_HM (@DT DATETIME)
RETURNS CHAR(5) AS
BEGIN
IF @DT IS NULL RETURN NULL
DECLARE @H INT
DECLARE @M INT
SET @H = DATEPART(HOUR, @DT)
SET @M = DATEPART(MINUTE, @DT)
DECLARE @RETVAL VARCHAR(5)
IF @H < 10
SET @RETVAL = '0' + CAST(@H AS CHAR(1))+':'
ELSE
SET @RETVAL = CAST(@H AS CHAR(2))+':'
IF @M < 10
SET @RETVAL = @RETVAL + '0' + CAST(@M AS CHAR(1))
ELSE
SET @RETVAL = @RETVAL + CAST(@M AS CHAR(2))
RETURN CAST(@RETVAL AS CHAR(5))
END
GO
der Aufruf erfolgt dann so:
SELECT dbo.FN_DATETIME_AS_HM(CURRENT_TIMESTAMP)
getestet mit Microsoft
SQL Server Management Studio Express. Es funktioniert also auf dem Server.
Raik