473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

6 months from now question

25
Hi,

Could someone help me with this problem? I can't seem to figure it out. I have a query that showed all total schedule hours based on month. But what I want is when user run the report, it will only show all hours within the next 6 months. For example, if I run the report today, then the report will show oct total, nov total, dec total, jan total, feb total, and mar total. How can I accomplish this task?

Thank you.
Oct 5 '09 #1

✓ answered by NeoPa

I never recommend formatting results in a query. This is likely to cause you problems down the line. The general rule is "Only ever format the data (convert the value to a string) at the last point where it is used for the operator."

Having said that, try the following :
Expand|Select|Wrap|Line Numbers
  1. SELECT   Format([INDATE],'YYYY - mm') AS [Month],
  2.          Sum([RemaininHours]) AS SumOfRemaininHours,
  3.          [RESOURCE_ID]
  4.  
  5. FROM     [resource_report]
  6.  
  7. WHERE    [INDATE] Between CDate('1 ' & Format(Date(),'mmm yyyy')) And
  8.                           CDate('1 ' & Format(DateAdd('m',6,Date()))-1
  9.  
  10. GROUP BY Format([INDATE],'YYYY - mm'),
  11.          [RESOURCE_ID]
  12.  
  13. ORDER BY Format([INDATE],'YYYY - mm')
I was still unable to determine from your posts whether current or past data should be handled, so I assumed it must be in this version. I have also assumed you intend the current month to be included in the 6 months. EG From 5 Oct 2009 this would include dates up to the end of March 2010. If this is not what you require then please explain clearly what you are looking for.

5 2007
NeoPa
32,556 Expert Mod 16PB
It's hard without any details of your project, but essentially you need to include in a WHERE clause :
Expand|Select|Wrap|Line Numbers
  1. ... [DateField]<DateAdd('m',6,Date())
Welcome to Bytes!
Oct 5 '09 #2
Bay0519
25
Hi Neopa,

Thank you for your quick response. My project is to know what kind of workload in the schedule for the next 6 months group by month. So I created a query to that show all the remaining hours based on indate

Expand|Select|Wrap|Line Numbers
  1.  SELECT (Format([INDATE],"YYYY - mm")) AS [month], Sum(resource_report.RemaininHours) AS SumOfRemaininHours, resource_report.RESOURCE_ID
  2. FROM resource_report
  3. GROUP BY (Format([INDATE],"YYYY - mm")), resource_report.RESOURCE_ID
  4. ORDER BY (Format([INDATE],"YYYY - mm")); 
this query will show me all the hours group by year and month. My question is, is it possible so when user opens a report, it will only show hours for the next 6 months? because the query will show all year and months that are in the resouce_report table.

Hope it won't confuse you more.
Oct 5 '09 #3
NeoPa
32,556 Expert Mod 16PB
I never recommend formatting results in a query. This is likely to cause you problems down the line. The general rule is "Only ever format the data (convert the value to a string) at the last point where it is used for the operator."

Having said that, try the following :
Expand|Select|Wrap|Line Numbers
  1. SELECT   Format([INDATE],'YYYY - mm') AS [Month],
  2.          Sum([RemaininHours]) AS SumOfRemaininHours,
  3.          [RESOURCE_ID]
  4.  
  5. FROM     [resource_report]
  6.  
  7. WHERE    [INDATE] Between CDate('1 ' & Format(Date(),'mmm yyyy')) And
  8.                           CDate('1 ' & Format(DateAdd('m',6,Date()))-1
  9.  
  10. GROUP BY Format([INDATE],'YYYY - mm'),
  11.          [RESOURCE_ID]
  12.  
  13. ORDER BY Format([INDATE],'YYYY - mm')
I was still unable to determine from your posts whether current or past data should be handled, so I assumed it must be in this version. I have also assumed you intend the current month to be included in the 6 months. EG From 5 Oct 2009 this would include dates up to the end of March 2010. If this is not what you require then please explain clearly what you are looking for.
Oct 5 '09 #4
Bay0519
25
It worked... Thank you so much.... :)
Oct 5 '09 #5
NeoPa
32,556 Expert Mod 16PB
It's always good to help :)
Oct 5 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Fabian | last post by:
Is there any way of determining when the first day of a *lunar* month (far eastern lunar months if it makes a difference) falls, using javascript? -- -- Fabian Visit my website often and...
2
by: sandy | last post by:
Hello, I am trying to automate a date. When typing in the issue date I want it to automatically calculate 6 months fronm the issue date and give me the Expiration date. Following is code that I am...
7
by: bryanilton | last post by:
I was hoping someone could help me with this.. I'm not very familiar with javascript but I'm pretty sure it can help me with what I need to accomplish. I've tried piecing several pieces of script...
5
by: John | last post by:
I'm building a table to store revenue and units sold data for products. What's the best design for storing the dates? Having 13 fields (year, Jan, Feb...Dec) or having 2 fields (year, month)? It...
2
by: lpeterson | last post by:
I'm trying to calculate the number of months between dates that begin in 2003 and end in 2004(ex. 1/2/2003 - 7/2/2004). I need the total months in 2003 and in 2004 both of which should add up to...
1
by: wz | last post by:
Hi, I'm new to access sql, and have a simple question. I have a date field, named log_dt, and I'm trying to count how many hours each record is from starting time of it's own month. But the 5 in...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
9
by: Robin Tucker | last post by:
Hiya, I need to test "relative dates" in my program, such as "last six months" or "last 3 months" or "in the last week" etc. How can I do this with a DateTime structure? ie. If NodeDate...
0
by: AlanF | last post by:
This may seem like a trivial question but I have been unable to figure this out. In .NET 2003, I'm trying to display 6 months using the MSFT calendar control. I am displaying the months in a 3x2...
1
by: raghav | last post by:
Hi I am working on ASP.NET 2.0 and C#. I am developing one application in which I have one field as Work Experience. For that I have 2 dropdown menus, one for year and other one for month. I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.