Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complicated SQL - can we make it?
Message
From
05/11/2000 00:05:00
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00437328
Message ID:
00438097
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
LOCAL dIncDate, aDateRange[1,2], cDateToStick, cMonthPart
SELECT MIN(DATE(val(cYear),val(cMonth),1)) as dmin, ;
       MAX(DATE(val(cYear),val(cMonth),1)) as dMax ;
  FROM InputTable ;
  INTO ARRAY aDateRange  && Save min and max 1st of month in array

SELECT 0
CREATE CURSOR tblPeriods ( cYearMonth C(6), ;
                           cYear C(4), ;
                           cMonth C(2), ;
                           cQuarter C(2) )

dIncDate = aDateRange[1,1]              && Start at first month
DO WHILE dIncDate <= aDateRange[1,2]    && For each month through the last
   cDateToStick = DTOS(dIncDate)        && Convert to YYYYMMDD 
   cMonthPart = SUBST(cDateToStick,5,2) && Snag MM

   INSERT INTO tblPeriods VALUES ( cDateToStick, ;
                                   cDateToStick, ;
                                   cMonthPart, ;
                                   'Q' + TRANSFORM(CEILING(VAL(cMonthPart)/3)) )

   dIncDate = GOMONTH(dIncDate,1)       && next month
ENDDO
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform