on 2018 May 31 4:32 PM
Buenos dias compañeros, tengo la siguiente consulta para convertir dia mes año, a año mes dia, hora minuto segundo
YYYY/MM/DD HH:MI:SS
SELECT T0."DocNum", T0."DocNum", T0."DocDate",T0."DocTime",
CONCAT(
CONCAT(
TO_DATE( CONCAT(
CAST(
extract(
YEAR FROM (T0."DocDate")
)
AS VARCHAR(10)
), ------
CONCAT( '/',-- CONCAT( -----
CAST(
extract(
MONTH FROM (T0."DocDate") )
AS VARCHAR(10)
),
CONCAT('/',
CAST(
extract(
DAY FROM (T0."DocDate")
)
AS VARCHAR(10)
)
)--
)
)
)
, 'YYYY/MM/DD')
, ' ' ------------------------------**********
),
CAST(
CONCAT(
CASE WHEN LENGTH (T0."DocTime")=4 THEN SUBSTRING ( T0."DocTime", 1,2)
WHEN LENGTH (T0."DocTime")=3 THEN SUBSTRING ( T0."DocTime", 1,1)
ELSE T0."DocTime"
END,
CONCAT(
CONCAT( ':',
CASE WHEN LENGTH (T0."DocTime")=4 THEN SUBSTRING ( T0."DocTime", 3,4)
WHEN LENGTH (T0."DocTime")=3 THEN SUBSTRING ( T0."DocTime", 2,4)
ELSE T0."DocTime"
END
), ':00'))
AS TIME)
)AS "FECHA 2"
FROM OINV T0
WHERE T0."DocDate" BETWEEN '2018-01-01' AND '2018-01-30'
La pregunta es si conocen una forma de hacer esto mas corto, ya que tuve muchos problemas en las conversiones TO_TIME y TO_DATE cuando el dato original del doctime y el docdate no tenia cumplía condiciones...
Espero me puedan ayudar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
9 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.