Thread: query
<div class="Section1"><p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">Hi,</span></font></b><p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold"> </span></font></b><p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">In oracle we write sysdate-1</span></font></b><p class="MsoNormal"><b><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">For example,we write a query (select * from table1 where created_date>=sysdate-1).Whatsits equivalent in postgre?</span></font></b><p class="MsoNormal"><b><font face="Tahoma"size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold"> </span></font></b><p class="MsoNormal"><b><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">Chandan</span></font></b><p class="MsoNormal"><b><font face="Tahoma" size="2"><spanstyle="font-size:10.0pt; font-family:Tahoma;font-weight:bold"> </span></font></b></div>
You should be able to use the CURRENT_DATE function in place of sysdate. You might need to cast the 1 explicitly to an interval. As in: CURRENT_DATE - '1 day'::interval -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Mar 17, 2005, at 4:57 AM, Chandan_Kumaraiah wrote: > Hi, > > In oracle we write sysdate-1 > > For example,we write a query (select * from table1 where > created_date>=sysdate-1).Whats its equivalent in postgre? > > Chandan
On Mon, Mar 21, 2005 at 08:33:43 -0600, "Thomas F.O'Connell" <tfo@sitening.com> wrote: > You should be able to use the CURRENT_DATE function in place of sysdate. > > You might need to cast the 1 explicitly to an interval. > > As in: > > CURRENT_DATE - '1 day'::interval I don't think you want that. That is going to force a conversion from date to a timestamp. You are going to be better off just using: current_date - 1