RE: VFP9-convert a number to month

2009-03-19 Thread Cathy Pountney
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,0.00)) ;
   FROM contract ;
   Group By 1,2 ;
   Order By 1,2 

Cathy



 -Original Message-
 From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com]
On
 Behalf Of Sytze de Boer
 Sent: Wednesday, March 18, 2009 8:49 PM
 To: profoxt...@leafe.com
 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 fbtay...@gmail.com wrote:
 
  Here's one way:
 
  ?CMONTH(EVALUATE({^++/+mm+/01}))
 
  convert your year and month as needed to character or if they're
numeric:
 
  ?CMONTH(DATE(,mm,1))
 
 
  On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz 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  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: ProFox@leafe.com
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.


Re: VFP9-convert a number to month

2009-03-19 Thread Stephen Russell
On Wed, Mar 18, 2009 at 6:37 PM, Sytze de Boer sy...@kiss.co.nz 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  mm, and I'm only concerned with the month

 I appreciate all pointers


I would make a DateDimension table that would join to ANY needed table
for getting any type of date dimension you need.

Date,  PKey
MonthNum,
MonthName,
MonthAbbr,
PeriodNum,
PeriodYear,
Quarter,
Year,
DOW,
CDayOfWeek

I have been doing this for years for DW reporting.

-- 
Stephen Russell
Sr. Production Systems Programmer
Web and Windows Development
Independent Contractor
Memphis TN

901.246-0159

___
Post Messages to: ProFox@leafe.com
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/c4313dbe0903190645n59b917c8le58d187ca4a44...@mail.gmail.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.


Re: VFP9-convert a number to month

2009-03-19 Thread Fred Taylor
What version of VFP are you using Cathy?  I doesn't work with VFP9/SP2.  As
soon as you add the GROUP BY with the 2nd field, it chokes (Function
argument value, type, or count is invalid.)

Fred


On Thu, Mar 19, 2009 at 5:27 AM, Cathy Pountney pro...@frontier2000.comwrote:

 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,0.00)) ;
   FROM contract ;
   Group By 1,2 ;
   Order By 1,2

 Cathy



  -Original Message-
  From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com]
 On
  Behalf Of Sytze de Boer
  Sent: Wednesday, March 18, 2009 8:49 PM
  To: profoxt...@leafe.com
  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 fbtay...@gmail.com
 wrote:
 
   Here's one way:
  
   ?CMONTH(EVALUATE({^++/+mm+/01}))
  
   convert your year and month as needed to character or if they're
 numeric:
  
   ?CMONTH(DATE(,mm,1))
  
  
   On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz
 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  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: ProFox@leafe.com
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/3392e7100903190746wa24099aq46c3619bc4ba6...@mail.gmail.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.


RE: VFP9-convert a number to month

2009-03-19 Thread Cathy Pountney
I'm using VFP 9 SP2 .. didn't choke for me. 

Do you have any records where the numeric field with the year/month is 0?
Maybe that is causing the problem. 

Cathy

 -Original Message-
 From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com]
On
 Behalf Of Fred Taylor
 Sent: Thursday, March 19, 2009 10:47 AM
 To: profoxt...@leafe.com
 Subject: Re: VFP9-convert a number to month
 
 What version of VFP are you using Cathy?  I doesn't work with VFP9/SP2.
As
 soon as you add the GROUP BY with the 2nd field, it chokes (Function
 argument value, type, or count is invalid.)
 
 Fred
 
 
 On Thu, Mar 19, 2009 at 5:27 AM, Cathy Pountney
 pro...@frontier2000.comwrote:
 
  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,0.00)) ;
FROM contract ;
Group By 1,2 ;
Order By 1,2
 
  Cathy
 
 
 
   -Original Message-
   From: profoxtech-boun...@leafe.com [mailto:profoxtech-
 boun...@leafe.com]
  On
   Behalf Of Sytze de Boer
   Sent: Wednesday, March 18, 2009 8:49 PM
   To: profoxt...@leafe.com
   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 fbtay...@gmail.com
  wrote:
  
Here's one way:
   
?CMONTH(EVALUATE({^++/+mm+/01}))
   
convert your year and month as needed to character or if they're
  numeric:
   
?CMONTH(DATE(,mm,1))
   
   
On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz
  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  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: ProFox@leafe.com
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/002101c9a8a3$7ee5ba10$7cb12e...@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.


Re: VFP9-convert a number to month

2009-03-19 Thread Fred Taylor
Nope a single test record (200811).  That was on my one system with the
early release of SP2 on it.  I'll have to try it on another system that has
the real SP2 on it, when I get a chance.

On Thu, Mar 19, 2009 at 8:00 AM, Cathy Pountney pro...@frontier2000.comwrote:

 I'm using VFP 9 SP2 .. didn't choke for me.

 Do you have any records where the numeric field with the year/month is 0?
 Maybe that is causing the problem.

 Cathy

  -Original Message-
  From: profoxtech-boun...@leafe.com [mailto:profoxtech-boun...@leafe.com]
 On
   Behalf Of Fred Taylor
  Sent: Thursday, March 19, 2009 10:47 AM
  To: profoxt...@leafe.com
  Subject: Re: VFP9-convert a number to month
 
  What version of VFP are you using Cathy?  I doesn't work with VFP9/SP2.
 As
  soon as you add the GROUP BY with the 2nd field, it chokes (Function
  argument value, type, or count is invalid.)
 
  Fred
 
 
  On Thu, Mar 19, 2009 at 5:27 AM, Cathy Pountney
  pro...@frontier2000.comwrote:
 
   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,0.00)) ;
 FROM contract ;
 Group By 1,2 ;
 Order By 1,2
  
   Cathy
  
  
  
-Original Message-
From: profoxtech-boun...@leafe.com [mailto:profoxtech-
  boun...@leafe.com]
   On
Behalf Of Sytze de Boer
Sent: Wednesday, March 18, 2009 8:49 PM
To: profoxt...@leafe.com
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 fbtay...@gmail.com
   wrote:
   
 Here's one way:

 ?CMONTH(EVALUATE({^++/+mm+/01}))

 convert your year and month as needed to character or if they're
   numeric:

 ?CMONTH(DATE(,mm,1))


 On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz
   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  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: ProFox@leafe.com
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/3392e7100903191306r74ad63e3q2c7c1d6ba2d18...@mail.gmail.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.


Re: VFP9-convert a number to month

2009-03-19 Thread Sytze de Boer
Fred, between you and Cathy you leave me for dead with your vfp knowledge,
so I'm watching your discussion with interest.

Sytze


On Fri, Mar 20, 2009 at 9:06 AM, Fred Taylor fbtay...@gmail.com wrote:

 Nope a single test record (200811).  That was on my one system with the
 early release of SP2 on it.  I'll have to try it on another system that has
 the real SP2 on it, when I get a chance.

 On Thu, Mar 19, 2009 at 8:00 AM, Cathy Pountney pro...@frontier2000.com
 wrote:

  I'm using VFP 9 SP2 .. didn't choke for me.
 
  Do you have any records where the numeric field with the year/month is 0?
  Maybe that is causing the problem.
 
  Cathy
 
   -Original Message-
   From: profoxtech-boun...@leafe.com [mailto:
 profoxtech-boun...@leafe.com]
  On
Behalf Of Fred Taylor
   Sent: Thursday, March 19, 2009 10:47 AM
   To: profoxt...@leafe.com
   Subject: Re: VFP9-convert a number to month
  
   What version of VFP are you using Cathy?  I doesn't work with VFP9/SP2.
  As
   soon as you add the GROUP BY with the 2nd field, it chokes (Function
   argument value, type, or count is invalid.)
  
   Fred
  
  
   On Thu, Mar 19, 2009 at 5:27 AM, Cathy Pountney
   pro...@frontier2000.comwrote:
  
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,0.00)) ;
  FROM contract ;
  Group By 1,2 ;
  Order By 1,2
   
Cathy
   
   
   
 -Original Message-
 From: profoxtech-boun...@leafe.com [mailto:profoxtech-
   boun...@leafe.com]
On
 Behalf Of Sytze de Boer
 Sent: Wednesday, March 18, 2009 8:49 PM
 To: profoxt...@leafe.com
 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 fbtay...@gmail.com
wrote:

  Here's one way:
 
  ?CMONTH(EVALUATE({^++/+mm+/01}))
 
  convert your year and month as needed to character or if they're
numeric:
 
  ?CMONTH(DATE(,mm,1))
 
 
  On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz
 
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  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: ProFox@leafe.com
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/367498c40903191309y7c19bfc2i6b74a2a4b04ca...@mail.gmail.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.


Re: VFP9-convert a number to month

2009-03-18 Thread Fred Taylor
Here's one way:

?CMONTH(EVALUATE({^++/+mm+/01}))

convert your year and month as needed to character or if they're numeric:

?CMONTH(DATE(,mm,1))


On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz 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  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: ProFox@leafe.com
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/3392e7100903181653s422878f0yb99d8c5488e52...@mail.gmail.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.


re: VFP9-convert a number to month

2009-03-18 Thread Joe Yoder
If an abbreviation will do - this works:

SUBSTR('JanFebMarAprMayJunJulAugSepOctNovDec', 1 + (MonthAsAnumber - 1) * 
3, 3)
If the month expression is character you need to convert it with VAL() - 
Joe Yoder

On Wednesday, March 18, 2009  7:37 PM, Sytze de Boer wrote:

Date: Thu, 19 Mar 2009 12:37:32 +1300
From: Sytze de Boer
To: profoxt...@leafe.com
cc:
Subject: VFP9-convert a number to month

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  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: ProFox@leafe.com
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/f5.dc.10174.13591...@cm-1.zoominternet.net
** 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.


Re: VFP9-convert a number to month

2009-03-18 Thread Sytze de Boer
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 fbtay...@gmail.com wrote:

 Here's one way:

 ?CMONTH(EVALUATE({^++/+mm+/01}))

 convert your year and month as needed to character or if they're numeric:

 ?CMONTH(DATE(,mm,1))


 On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz 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  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: ProFox@leafe.com
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/367498c40903181749we840198oebf3f9fb53148...@mail.gmail.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.


Re: VFP9-convert a number to month

2009-03-18 Thread Fred Taylor
OK, I see what may be the problem.  It's probably FoxPro's attempt at
determining the field size when it starts the query.

Try this instead:

cMonths = JAN~FEB~MAR~APR~MAY~JUN~JUL~AUG~SEP~OCT~NOV~DEC
=ALINES(aMonths,cMonths,.t.,~)
SELECT client,CL+aMonths[saleperiod-(INT(saleperiod/100)*100)] ;
  FROM winhst INTO CURSOR xyz
SELECT * FROM xyz GROUP BY 1,2 ORDER BY 1,2

Take two passes at the data, 1 to get the value you need and 2 to get the
grouping.  I also used an array to simplify some of the other code.


Fred


On Wed, Mar 18, 2009 at 5:49 PM, Sytze de Boer sy...@kiss.co.nz wrote:

 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 fbtay...@gmail.com wrote:

  Here's one way:
 
  ?CMONTH(EVALUATE({^++/+mm+/01}))
 
  convert your year and month as needed to character or if they're numeric:
 
  ?CMONTH(DATE(,mm,1))
 
 
  On Wed, Mar 18, 2009 at 4:37 PM, Sytze de Boer sy...@kiss.co.nz 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  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: ProFox@leafe.com
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/3392e7100903181846x4f7b5fd9n5adfc85576b61...@mail.gmail.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.