473,666 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dateserial for previous year??

9 New Member
I am needing to calculate a month to date for the previous year in a report. Example: today is 02/18/10 and I have a month to date for today(current year). I need the report to also show month to date for 02/18/09. I believe I would be able to manipulate my current formula that figures the month to date for the current year, but I have been unsuccessful so far. I have the current year, month to date formula of:
Expand|Select|Wrap|Line Numbers
  1. =DAvg("[Occpncy Rate Skill Level]","[Service Guarentee Daily QRY]","Date Between #" & DateAdd("d",-Day([Date])+1,[Date]) & "# AND #" & [Date] & "#")
and I am using the grouping in the report for the month. I am pretty much a novice in comparison to most out here, any help would be appreciated. Thanks
Feb 18 '10 #1
7 6207
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi there and welcome to Bytes

1) You should avoid using Date as a field name as it is a reserved word, and might end up causing you alot of headache.

2) To subtract a year from field myDate you would do:
Expand|Select|Wrap|Line Numbers
  1. myOldDate = DateAdd("yyyy", -1, myDate)
DateAdd's first parameter specifies that we wish to add years ("yyyy") but you could also use "d" for days, or "m" for months.
Second paramter -1 tells the function we wish to ADD -1 years, lastly the myDate is the date we wish to add the -1 year to.

3) Please remember to use the code tags around your code [code][/code]. It makes it a bit easier to read.
Feb 18 '10 #2
beaudreaux
9 New Member
I may not be putting 2 & 2 together. I did get to show me the date one year ago. But, how do I get it to show me the data from a year ago? I want the report field to show the previous year data (year to date). I'm not sure if I can reference the field I already have that is doing the calculation already and have it display the previous year?
Feb 22 '10 #3
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I've read your post but im not sure im making sense of what your trying to acomplish.
If you want all rows made in the last year, and you have a field called myDate you could select them using a query:
Expand|Select|Wrap|Line Numbers
  1. SELECT * from myTable where myDate>dateAdd("yyyy",-1,Date())
Feb 22 '10 #4
beaudreaux
9 New Member
Sorry for the confusion. I will try to explain further here. I have a query Service Guarentee QRY with a field named Occpncy Rate Skill Level. From this I have a report that shows the daily volume, a month to date. I need to add a third field in the report that will show what the month to date on that day for the previous year was. Each would have a calculated result.
Day (1/25/10) MTD(1/1/10-1/25/10) MTD prior year (1/1/09-1/25/09)
The formula listed at the start calculates the MTD of the current year. So I am not sure if I can reference that and some how pull the data from the previous year or how to reference that data?? Hope this helps some.
Feb 23 '10 #5
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
What is a "Month to date"?
Feb 23 '10 #6
beaudreaux
9 New Member
It is a running sum calculated from the start of a month to the current day of the month and would start over each month. Example 01/01/10 - 1/2/10, 1/1/10 - 1/3/10, 1/1/10 - 1/4/10, 1/1/10 - 1/5/10 and so on until the end of the month. I have this already calculated but I need to get the numbers of the MTD for the prior year (which has already been calculated). I need to some how reference that prior year data in my report.
Feb 24 '10 #7
beaudreaux
9 New Member
I may have misunderstood the question. The month to day is the timeframe of the data I am calculating. I have this calculated already but I need to be able to reference the prior year data for the month to date. So I need to get the data that would show 2/1/09 - 2/24/09 (for current examle of time frame)
Feb 24 '10 #8

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

Similar topics

2
2278
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; DateDiff("y",-4,DateIn) and get errors Please any assistance would be greatly appreciated. Michael
1
4979
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
5
2639
by: Jeremy Wallace | last post by:
I have some code that uses DateSerial to populate a couple of text boxes on a form. I was doing some testing this afternoon and found that I get funny values if the year supplied is 99. 98 works fine. 04 works fine. 1999 works fine. 100 works fine. But 98 gives a funny value. Anyone have thoughts on why, or how to re-form the dateserial call to deal with this? Here's some results from the immediate window: ?(DateSerial(98 , 12+ 1, 1)) -...
1
4052
by: Terencetrent | last post by:
I have created a query that examines qarterly sales for 5 regions in the country. The query contains data for the past 6 quarters for each region and calculates the perecentage of total sales for the quarter fo each region. To help enhance the report I would love to include a comparison to of current sales to previous quarter sales and a comparison of current sales to sales a year ago. I am having a devil of a time creating a query to...
3
2580
by: ralph_noble | last post by:
Greetings ... I have a table named Harms and Steven with a field named inspector (text) and inspection date (date/time). I need to count up how many times the inspector appears for any inspections occured in 2004. Here's what I have, but it's giving me problems ... what am I doing wrong? Thanks.
1
15263
by: Kenny | last post by:
I am having issues with the "Date.ToOADate" method in VB .NET. I understand that in VB6 the function DateSerial gives an internal representation of the date. When I use the DateSerial method in VB .Net, dragging the mouse over to the statement, VB .NET reports the following "Conversion from 'Date' to "Double' requires calling the 'Date.ToOAdate' method. When I tyoe this method in, the syntax checker undelines
5
3206
by: jerry.ranch | last post by:
I see that DateSerial can be used to "concatenate", in a way, three fields DateSerial(year, month day) into a date field (if year , month and date are numeric values). Unfortunately, my Month field is Text (January, February etc). What function is used to convert text month to numerical 1-12? Thanks Jerry
1
1560
by: woooopa | last post by:
Something like this... MAX (DateSerial(!,!,!))
3
2679
by: RZ15 | last post by:
Hi, I have a query that calculates the sum of branch transfers for the current quarter. Here is my Quarter-to-Date field: QTD-In: Sum(CCur(IIf(="TRN" And Between DateSerial(Year(Date()),Int((Month(Date())-1)/3)*3+1,1) And DateSerial(Year(Date()),Int((Month(Date())-1)/3)*3+4,0),*!,0))) Now, I need to make sure I understand the DateSerials, which I think I do but I'd rather be safe than sorry. For DateSerial(Year(Date()),...
3
5802
by: ringer | last post by:
On a form I have a combo where a month is entered. It shows the month names in column one, but it is bound to column two where each month's corresponding number is, ie Jan=1, Feb=2, etc. So selecting April returns 4. Also on the form I have a text box where a number is entered and used as the date of the month in the aforementioned combo box. I pull those numbers (month number from the combo and date number from the text box) together...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.