RES: How to add days to date

From: "Alejandro Michelin Salomon \( Adinet \)" <alejmsg(at)adinet(dot)com(dot)uy>
To: "'Michael Fuhr'" <mike(at)fuhr(dot)org>
Cc: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: RES: How to add days to date
Date: 2006-08-16 11:13:48
Message-ID: !~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAhx491Ki2tUS42D/aMPFg1MKAAAAQAAAAa1sgrw2Jn0a8FtqX4ZfxZwEAAAAA@adinet.com.uy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael :

I change my query to this :

SELECT CAST( '2006-08-01' AS DATE ) + FP.carencia + ( FP.prazo * (
MFP.parcela - 1 )) AS vencimento
FROM fi_mov_formas_pagamento MFP
LEFT OUTER JOIN fi_formas_pagamento FP ON ( MFP.idformapagamento =
FP.idformapagamento AND MFP.idempresa = FP.idempresa )
INNER JOIN hd_cabecalho HDC ON ( MFP.idmovimento = HDC.idhelpdesk AND
MFP.idempresa = HDC.idempresa )
WHERE MFP.idmovimento = 1
AND MFP.idempresa = 1
AND MFP.idtipomovimentacao = 1

And i run ok now.

Thanks for your help.

Alejandro

-->-----Mensagem original-----
-->De: Michael Fuhr [mailto:mike(at)fuhr(dot)org]
-->Enviada em: terça-feira, 15 de agosto de 2006 22:17
-->Para: Alejandro Michelin Salomon ( Adinet )
-->Cc: Pgsql-General
-->Assunto: Re: [GENERAL] How to add days to date
-->
-->
-->On Tue, Aug 15, 2006 at 10:10:27PM -0300, Alejandro Michelin
-->Salomon ( Adinet ) wrote:
-->> EX :
-->> '2006-08-01' + 30 + ( 7 * ( 3 - 1 )) ==> '2006-08-01' + 44
-->>
-->> All my trys fails.
-->
-->The error message hints at what's wrong:
-->
-->test=> SELECT '2006-08-01' + 30 + (7 * (3 - 1));
-->ERROR: invalid input syntax for integer: "2006-08-01"
-->
-->PostgreSQL doesn't know that the untyped string is supposed
-->to be interpreted as a date. Use a cast:
-->
-->test=> SELECT '2006-08-01'::date + 30 + (7 * (3 - 1));
--> ?column?
-->------------
--> 2006-09-14
-->(1 row)
-->
-->or
-->
-->test=> SELECT CAST('2006-08-01' AS date) + 30 + (7 * (3 - 1));
--> ?column?
-->------------
--> 2006-09-14
-->(1 row)
-->
-->--
-->Michael Fuhr
-->

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Poul Møller Hansen 2006-08-16 11:59:46 Segmentation Fault
Previous Message Graeme Hinchliffe 2006-08-16 10:17:57 Massive slowdown when LIMIT applied