I took your second expression, and switched out fields with stuff in my data so I could test and it worked just fine for me. I didn't have any group by problem. I did, however, shorten up the expression using MOD() on the date to get the month and I just hard-coded the year because it doesn't matter to the results:
SELECT client, ; "CL"+UPPER(LEFT(CMONTH(DATE(2008,MOD(saleperiod,100),1)),3)), ; Sum(Iif(.t.,bprice,00000.00)) ; FROM contract ; Group By 1,2 ; Order By 1,2 Cathy > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Sytze de Boer > Sent: Wednesday, March 18, 2009 8:49 PM > To: [email protected] > Subject: Re: VFP9-convert a number to month > > Thanks Fred > I now encounter a problem with the "group and order by" > > Original goes like this (no problem but I want to refine it) > *Select client,"CL"+Upper(Left(Cmonth(invdate),3)), > Sum(Iif(trantype='I',ttlamount-(ttlamount*(ppb/100)),ttlamount*-1)) ; > *FROM winhst Where Between(saleperiod,psdate1,psdate2) And trantype $ > "CI" And client=windebs.Code Group By 1,2 Order By 1,2 Into Table &myfile > > Select > client,"CL"+UPPER(LEFT(CMONTH(DATE(INT(saleperiod/100),saleperiod- > (INT(saleperiod/100)*100),1)),3)), > Sum(Iif(trantype='I',ttlamount-(ttlamount*(ppb/100)),ttlamount*-1)) ; > FROM winhst Where Between(saleperiod,psdate1,psdate2) And trantype $ > "CI" > And client=windebs.Code Group By 1,2 Order By 1,2 Into Table &myfile > > This causes a problem on the group and order by > If I group and order by 1 its ok > > > > > > > On Thu, Mar 19, 2009 at 12:53 PM, Fred Taylor <[email protected]> wrote: > > > Here's one way: > > > > ?CMONTH(EVALUATE("{^"+"yyyy"+"/"+"mm"+"/01}")) > > > > convert your year and month as needed to character or if they're numeric: > > > > ?CMONTH(DATE(yyyy,mm,1)) > > > > > > On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer <[email protected]> wrote: > > > > > Hi > > > > > > I know how to do cmonth(date()) and various derivatives thereof > > > How do convert a number to a month ? > > > > > > This is be done in a select statement where 1 field is (say 200804 or > > > 200805) > > > The numbers are consistent yyyy mm, and I'm only concerned with the > month > > > > > > I appreciate all pointers > > > > > > -- > > > Regards > > > Sytze de Boer > > > Kiss Systems > > > Hamilton, NZ > > > Ph: 64-7-8391670, Mob:021 937611, > > > www.kiss.co.nz > > > > > > > > > --- StripMime Report -- processed MIME parts --- > > > multipart/alternative > > > text/plain (text body -- kept) > > > text/html > > > --- > > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/001001c9a88e$0580f690$1082e3...@com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

