0

//Get the TIME part of a DATETIME, truncated to MINUTES.

DROP ROUTINE IF EXISTS RoundedTime;
CREATE FUNCTION RoundedTime( DateTimeOrig DATETIME)
RETURNS TIME
DETERMINISTIC
BEGIN
  DECLARE Horas INTEGER;
  DECLARE Minutos INTEGER;
  DECLARE SHoras CHAR(2);
  DECLARE SMinutos CHAR(2);

  SET Horas = EXTRACT(HOUR FROM DateTimeOrig);
  SET Minutos = EXTRACT(MINUTE FROM DateTimeOrig);
  SET SHoras = ToString(Horas);
  IF Horas < 10 THEN
    SET SHoras = '0' || SHoras;
  END IF;
  SET SMinutos = ToString(Minutos);
  IF Minutos < 10 THEN
    SET SMinutos = '0' || SMinutos;
  END IF;
  RETURN CAST( SHoras || ':' || SMinutos || ':00' AS TIME);
END;
Category: 
SQL Functions & Procedures
Current Version: 
1.00
Supported Products: 
NexusDB V2
NexusDB V3
Home