Results 1 to 4 of 4

Thread: Convert Function in MySQL

  1. #1
    jjprabhu is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    19

    Default Convert Function in MySQL

    Hello everyone,

    Earlier when i used sugarcrm 4.5 with MSSQL, i had used the following query for generating a report:


    select o.name as "Opp. name",u.first_name+' '+u.last_name as "Opp. Assigned to"
    from opportunities o,users u
    where sales_stage='Prospecting'
    and u.id=o.assigned_user_id
    and convert(datetime,convert(char(11),o.date_entered,1 01)) >= convert(datetime,$P{startdate},101)
    AND convert(datetime,convert(char(11),o.date_entered,1 01)) <= convert(datetime,$P{enddate},101)
    group by o.name,u.first_name,u.last_name
    order by u.first_name,u.last_name


    But now when im using Mysql it is throwing some error:

    are there any syntax changes in the convert() for MySQL...

    Please help me in solving this issue

    Thanks in advance

  2. #2
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Convert Function in MySQL

    Try

    select o.name as "Opp. name",u.first_name+' '+u.last_name as "Opp. Assigned to"
    from opportunities o,users u
    where sales_stage='Prospecting'
    and u.id=o.assigned_user_id
    and DATE(o.date_entered) between $P{startdate}, AND $P{enddate}
    group by o.name,u.first_name,u.last_name
    order by u.first_name,u.last_name
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  3. #3
    agcopley is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Santiago, Chile
    Posts
    204

    Default Re: Convert Function in MySQL

    Hi there,
    A look in the mysql manual gives convert

    CONVERT(expr,type), CONVERT(expr USING transcoding_name)

    where type = datetime etc.

    it appears they have reversed the order of the parameters for your function.


    Rgds
    Andrew

  4. #4
    jjprabhu is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    19

    Default Re: Convert Function in MySQL

    thanks mikesolomon for your prompt reply...

    I have come up across yet another issue......

    suppose a Team leader wants a count of the leads which are assigned to his team members(ie. users)..
    How can this be done......

    I have used the following query........

    select l.first_name "Lead's First name",l.last_name "Lead's Last name",u.user_name "User's name" from users u,leads l, teams t, team_membership tm
    where
    u.id= "$SUGAR_USER_ID"
    u.id=l.assigned_user_id
    and u.id=tm.user_id
    and t.id=tm.team_id

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Query Failed: AND users.id = '1'::MySQL error 1064:
    By artco001 in forum Installation and Upgrade Help
    Replies: 63
    Last Post: 2009-05-07, 05:56 AM
  2. Replies: 5
    Last Post: 2007-11-13, 02:51 PM
  3. Replies: 0
    Last Post: 2007-08-08, 02:47 PM
  4. Huge backups -- normal?
    By Liam in forum Help
    Replies: 5
    Last Post: 2007-05-02, 05:36 AM
  5. Replies: 7
    Last Post: 2007-02-14, 03:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •