473,386 Members | 1,820 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,386 software developers and data experts.

Same day, previous year

jiffylube
I'm putting together a retail comp report that compares the current day stats to the same day, previous year. Is there a code I can use to get last year, same day?
For example: This year stats= 7/22/2007-Sunday
Previous year= 7/23/2006-Sunday
I need to be able to put this string into the design view in a criteria field. For Calendar comp I use the following.
This year: >=DateSerial(Year(Date()),Month(Date()),1) And <=Date()-1
Last year:>=DateSerial(Year(Date())-1,Month(Date()),1) And <=Date()-366

Can this be done for same day is what I'm wondering? Any help would be greatly appreciative.

I'm currently running Windows XP Pro SP1 and MS Access 2000
Jul 23 '07 #1
4 10491
Rabbit
12,516 Expert Mod 8TB
DateAdd("yyyy", -1, SomeDate)
Jul 23 '07 #2
missinglinq
3,532 Expert 2GB
I believe you'll find that code will give you the same date from the previous year but not the same weekday.

This year stats= 7/22/2007-Sunday
Previous year= 7/23/2006-Sunday
It will produce, instead

Previous year= 7/22/2006-Saturday

What you need is to use 52 weeks instead:
Expand|Select|Wrap|Line Numbers
  1. DateAdd("ww", -52, SomeDate)
Welcome to TheScripts!

Linq ;0)>
Jul 23 '07 #3
Rabbit
12,516 Expert Mod 8TB
I believe you'll find that code will give you the same date from the previous year but not the same weekday.

It will produce, instead

Previous year= 7/22/2006-Saturday

What you need is to use 52 weeks instead:
Expand|Select|Wrap|Line Numbers
  1. DateAdd("ww", -52, SomeDate)
Welcome to TheScripts!

Linq ;0)>
Ahh, missed that part of the post.
Jul 23 '07 #4
missinglinq
3,532 Expert 2GB
I probably just caught it because I did the same thing, in reverse (add 1 year and end up on the same weekday) for someone elsewhere this past weekend!

Linq ;0)>
Jul 23 '07 #5

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

Similar topics

0
by: MT | last post by:
hi all, I have a view that has data from this year as well as previous years. the select statment looks something like this: create view as select year, costs_mon1, costs_mon2, costs_mon3...
2
by: John | last post by:
If anyone can help me out with a good way to do this in javascript I would greatly appreciate it. I need to compute three dates in javascript - all of which relate to a given date, say todays...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
1
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...
2
by: Bernd Hohmann | last post by:
Dear collegues, small query problem. A table (simplified example)... customer as char(5) inv_date as date amount as double
5
by: rjfjohnson | last post by:
Hey, Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05. Because I am comparing daily sales between years, I need to know the date of the same weekdayname as last year, so...
3
by: jannoergaard | last post by:
Hi I want to write a function that can return a sum for a given date range. The same function should be able to return the sum for the same period year before. Let me give an example: The...
6
by: Dixie | last post by:
I have asked this question before, but I could not get the suggested solution work. So I will give more details this time. I have an append query that adds several hundred records to a table...
9
by: brymcguire | last post by:
Hi, I have a requirement to design a query that identifies items sold between two dates. There is a 'SoldDate' datetime field used to register what date the item was sold. The query needs...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.