RES: How to add days to date - Mailing list pgsql-general

From Alejandro Michelin Salomon \( Adinet \)
Subject RES: How to add days to date
Date
Msg-id !~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAhx491Ki2tUS42D/aMPFg1MKAAAAQAAAAa1sgrw2Jn0a8FtqX4ZfxZwEAAAAA@adinet.com.uy
Whole thread Raw
In response to Re: How to add days to date  (Michael Fuhr <mike@fuhr.org>)
List 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@fuhr.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
-->


pgsql-general by date:

Previous
From: Graeme Hinchliffe
Date:
Subject: Massive slowdown when LIMIT applied
Next
From: Poul Møller Hansen
Date:
Subject: Segmentation Fault