Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Experts I am trying to extract data for the last three months. This is m current code. This particular code pulls the data from January to th end of September. I would like to pull only from July to the end o September. How do I go about modifying my code to do this? ![]() Code ------------------- cn.Open cString For m = 1 To curMonth - 1 MerchantMonthly = "select branch, sum(qty), sum(b.vat)" & _ " from service_providers a left outer join cb b on a.sp_name = b.sp_name and month" & _ " (inv_date) = " & m & " and year(inv_date) = " & curYear & " order by a.sp_name" If rs.State = -1 Then rs.Close rs.Open MerchantMonthly, cn, adOpenKeyset, adLockOptimistic, adCmdText 'dump data into excel by calling function Call PopulatePage(m ------------------- I'm getting the data from SQL server. Kind Regard -- popp ----------------------------------------------------------------------- poppy's Profile: http://www.excelforum.com/member.php...fo&userid=1145 View this thread: http://www.excelforum.com/showthread.php?threadid=26604 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would think:
For m = curMonth - 3 To curMonth - 1 -- Jim Rech Excel MVP "poppy" wrote in message ... | | Hi Experts | | I am trying to extract data for the last three months. This is my | current code. This particular code pulls the data from January to the | end of September. I would like to pull only from July to the end of | September. How do I go about modifying my code to do this? ![]() | | Code: | -------------------- | cn.Open cString | | For m = 1 To curMonth - 1 | | MerchantMonthly = "select branch, sum(qty), sum(b.vat)" & _ | " from service_providers a left outer join cb b on a.sp_name = b.sp_name and month" & _ | " (inv_date) = " & m & " and year(inv_date) = " & curYear & " order by a.sp_name" | | If rs.State = -1 Then rs.Close | | rs.Open MerchantMonthly, cn, adOpenKeyset, adLockOptimistic, adCmdText | | | 'dump data into excel by calling function | Call PopulatePage(m) | -------------------- | | | I'm getting the data from SQL server. | | Kind Regards | | | -- | poppy | ------------------------------------------------------------------------ | poppy's Profile: http://www.excelforum.com/member.php...o&userid=11453 | View this thread: http://www.excelforum.com/showthread...hreadid=266048 | |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
For m = curMonth - 4 To curMonth - 1 -- Regards, Tom Ogilvy "poppy" wrote in message ... Hi Experts I am trying to extract data for the last three months. This is my current code. This particular code pulls the data from January to the end of September. I would like to pull only from July to the end of September. How do I go about modifying my code to do this? ![]() Code: -------------------- cn.Open cString For m = 1 To curMonth - 1 MerchantMonthly = "select branch, sum(qty), sum(b.vat)" & _ " from service_providers a left outer join cb b on a.sp_name = b.sp_name and month" & _ " (inv_date) = " & m & " and year(inv_date) = " & curYear & " order by a.sp_name" If rs.State = -1 Then rs.Close rs.Open MerchantMonthly, cn, adOpenKeyset, adLockOptimistic, adCmdText 'dump data into excel by calling function Call PopulatePage(m) -------------------- I'm getting the data from SQL server. Kind Regards -- poppy ------------------------------------------------------------------------ poppy's Profile: http://www.excelforum.com/member.php...o&userid=11453 View this thread: http://www.excelforum.com/showthread...hreadid=266048 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sum the data for specified months | Excel Discussion (Misc queries) | |||
Transpose data Months & Data to Rows | Excel Discussion (Misc queries) | |||
I want to put 1 years data and 1 months data togheter on one char. | Charts and Charting in Excel | |||
Last Months Data!! | Excel Worksheet Functions | |||
Dates to months and calculating values for their months | Excel Programming |