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.
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 : - SELECT Format([INDATE],'YYYY - mm') AS [Month],
-
Sum([RemaininHours]) AS SumOfRemaininHours,
-
[RESOURCE_ID]
-
-
FROM [resource_report]
-
-
WHERE [INDATE] Between CDate('1 ' & Format(Date(),'mmm yyyy')) And
-
CDate('1 ' & Format(DateAdd('m',6,Date()))-1
-
-
GROUP BY Format([INDATE],'YYYY - mm'),
-
[RESOURCE_ID]
-
-
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 : - ... [DateField]<DateAdd('m',6,Date())
Welcome to Bytes!
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 - SELECT (Format([INDATE],"YYYY - mm")) AS [month], Sum(resource_report.RemaininHours) AS SumOfRemaininHours, resource_report.RESOURCE_ID
-
FROM resource_report
-
GROUP BY (Format([INDATE],"YYYY - mm")), resource_report.RESOURCE_ID
-
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.
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 : - SELECT Format([INDATE],'YYYY - mm') AS [Month],
-
Sum([RemaininHours]) AS SumOfRemaininHours,
-
[RESOURCE_ID]
-
-
FROM [resource_report]
-
-
WHERE [INDATE] Between CDate('1 ' & Format(Date(),'mmm yyyy')) And
-
CDate('1 ' & Format(DateAdd('m',6,Date()))-1
-
-
GROUP BY Format([INDATE],'YYYY - mm'),
-
[RESOURCE_ID]
-
-
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.
It worked... Thank you so much.... :)
NeoPa 32,556
Expert Mod 16PB
It's always good to help :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |