Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to use timestamp without timezone create_date in postgresql select query

By
gpkarthick
on 5/8/13, 3:19 AM 1,850 views

select rp.name, cl.name,cl.date_open,cl.state, he.lead_target, count(cl.user_id) as achieved, round(((cast(count(cl.user_id) as decimal(2))/he.lead_target)*100)) as val from crm_lead cl, hr_employee he, res_users rs, res_partner rp where cl.type='opportunity' and
rs.id=he.user_id and he.user_id=cl.user_id and rp.id=rs.partner_id and create_date>='2013-04-28' and create_date<=now() + interval '15 days' group by rp.name, he.lead_target,cl.name,cl.date_open,cl.state--->shows error

1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 5/11/13, 11:24 AM

Hi,

try :

from datetime import datetime, timedelta

from dateutil.relativedelta import relativedelta

cr.execute("""select rp.name, cl.name,cl.date_open,cl.state,
he.lead_target, 
count(cl.user_id) as achieved,
round(((cast(count(cl.user_id) as decimal(2))/he.lead_target)*100)) as val
from crm_lead cl, 
hr_employee he, 
res_users rs, 
res_partner rp
where cl.type='opportunity' and  
rs.id=he.user_id and 
he.user_id=cl.user_id and
rp.id=rs.partner_id and 
create_date>='2013-04-28' and create_date<=%s
""", (str(datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') + relativedelta(days=15).strftime('%Y-%m-%d %H:%M:%S.%f')),))

Bye

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/8/13, 3:19 AM
Seen: 1850 times
Last updated: 3/16/15, 8:10 AM