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

Same date data for 12 months how?

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,
IT.itemid,
IT.date,
IT.Qty,
IT.Rate,
IT.Amount
FROM ITran as IT
INNER JOIN
IMast as IM
ON IT.itemid = IM.itemid
WHERE IT.itemid="A101"
and (IT.date='01DEC2003'd
or IT.date='01DEC2003'd-30
or IT.date='01DEC2003'd-61
or IT.date='01DEC2003'd-91
or IT.date='01DEC2003'd-122
or IT.date='01DEC2003'd-153
or IT.date='01DEC2003'd-183
or IT.date='01DEC2003'd-214
or IT.date='01DEC2003'd-244
or IT.date='01DEC2003'd-275
or IT.date='01DEC2003'd-303
or IT.date='01DEC2003'd-334
or IT.date='01DEC2003'd-365)
order by IM.Area, IT.itemid, IT.date desc;
quit;

Captain
Nov 13 '05 #1
3 2554
What data type is IT.Date? "IT.date='01DEC2003'd-30" is not a standard
date/time field type. Is the value actually a date and you are attempting to
subtract 30 from the date of 01 DEC 2003? It appears that what you want is
the value on the first day of the month (+/- 5 days) for the previous 12
months. Is this correct?

--
Wayne Morgan
MS Access MVP
"captain" <ca**********@yahoo.com> wrote in message
news:27**************************@posting.google.c om...
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,
IT.itemid,
IT.date,
IT.Qty,
IT.Rate,
IT.Amount
FROM ITran as IT
INNER JOIN
IMast as IM
ON IT.itemid = IM.itemid
WHERE IT.itemid="A101"
and (IT.date='01DEC2003'd
or IT.date='01DEC2003'd-30
or IT.date='01DEC2003'd-61
or IT.date='01DEC2003'd-91
or IT.date='01DEC2003'd-122
or IT.date='01DEC2003'd-153
or IT.date='01DEC2003'd-183
or IT.date='01DEC2003'd-214
or IT.date='01DEC2003'd-244
or IT.date='01DEC2003'd-275
or IT.date='01DEC2003'd-303
or IT.date='01DEC2003'd-334
or IT.date='01DEC2003'd-365)
order by IM.Area, IT.itemid, IT.date desc;
quit;

Captain

Nov 13 '05 #2
Wayne,

it.date is a date field. Typo error
Yes, looking for extraction of same date
for previous consecutive month.

There after, have to do a subtraction i.e.

Date qty Diff (i.e. 5 - 4 = +1 also looking for this value to display)
5/1/2004 5 +1
4/1/2004 4
Captain

"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<Q2***************@newssvr22.news.prodigy.com >...
What data type is IT.Date? "IT.date='01DEC2003'd-30" is not a standard
date/time field type. Is the value actually a date and you are attempting to
subtract 30 from the date of 01 DEC 2003? It appears that what you want is
the value on the first day of the month (+/- 5 days) for the previous 12
months. Is this correct?

--
Wayne Morgan
MS Access MVP
"captain" <ca**********@yahoo.com> wrote in message
news:27**************************@posting.google.c om...
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,
IT.itemid,
IT.date,
IT.Qty,
IT.Rate,
IT.Amount
FROM ITran as IT
INNER JOIN
IMast as IM
ON IT.itemid = IM.itemid
WHERE IT.itemid="A101"
and (IT.date='01DEC2003'd
or IT.date='01DEC2003'd-30
or IT.date='01DEC2003'd-61
or IT.date='01DEC2003'd-91
or IT.date='01DEC2003'd-122
or IT.date='01DEC2003'd-153
or IT.date='01DEC2003'd-183
or IT.date='01DEC2003'd-214
or IT.date='01DEC2003'd-244
or IT.date='01DEC2003'd-275
or IT.date='01DEC2003'd-303
or IT.date='01DEC2003'd-334
or IT.date='01DEC2003'd-365)
order by IM.Area, IT.itemid, IT.date desc;
quit;

Captain

Nov 13 '05 #3
To get the same date for the previous 12 months, you need to put criteria on
two fields.

First Field:
Field - DateNeeded:(([IT].[Date]>=DateSerial(Year([IT].[Date]),
Month([IT].[Date]), 6-5)) And ([IT].[Date]<=DateSerial(Year([IT].[Date]),
Month([IT].[Date]), 6+5)))
Criteria - True

This will return True or False if IT.Date is 6 +/- 5 days. You will have to
verify that this is a valid day for all months (i.e. <=28) or you won't get
the results you expect. This will error out if any of the records contain a
Null value in IT.Date.

Second Field:
Field - [IT].[Date]
Criteria - >= DateAdd("m", -12, [IT].[Date])

This will give you 7/21/2003 or later if today is 7/21/2004. If you want to
include all of July 2003 then the Second Field should be:

Field - MonthsBack: Format([IT].[Date], "yyyymm")
Criteria - >= Format(DateAdd("m", -12, [IT].[Date]), "yyyymm")

This will use just the year and month values. So, today would show up a
200407 and 12 months ago would show up as 200307.

Just a quick comment, you shouldn't use a reserved word, such as Date, as
the name of a field, variable, or other items. This will prevent Access from
confusing it with the Date function in VBA.

--
Wayne Morgan
Microsoft Access MVP
"captain" <ca**********@yahoo.com> wrote in message
news:27**************************@posting.google.c om...
Wayne,

it.date is a date field. Typo error
Yes, looking for extraction of same date
for previous consecutive month.

There after, have to do a subtraction i.e.

Date qty Diff (i.e. 5 - 4 = +1 also looking for this value to
display)
5/1/2004 5 +1
4/1/2004 4
Captain

"Wayne Morgan" <co***************************@hotmail.com> wrote in
message news:<Q2***************@newssvr22.news.prodigy.com >...
What data type is IT.Date? "IT.date='01DEC2003'd-30" is not a standard
date/time field type. Is the value actually a date and you are attempting
to
subtract 30 from the date of 01 DEC 2003? It appears that what you want
is
the value on the first day of the month (+/- 5 days) for the previous 12
months. Is this correct?

--
Wayne Morgan
MS Access MVP
"captain" <ca**********@yahoo.com> wrote in message
news:27**************************@posting.google.c om...
> 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,
> IT.itemid,
> IT.date,
> IT.Qty,
> IT.Rate,
> IT.Amount
> FROM ITran as IT
> INNER JOIN
> IMast as IM
> ON IT.itemid = IM.itemid
> WHERE IT.itemid="A101"
> and (IT.date='01DEC2003'd
> or IT.date='01DEC2003'd-30
> or IT.date='01DEC2003'd-61
> or IT.date='01DEC2003'd-91
> or IT.date='01DEC2003'd-122
> or IT.date='01DEC2003'd-153
> or IT.date='01DEC2003'd-183
> or IT.date='01DEC2003'd-214
> or IT.date='01DEC2003'd-244
> or IT.date='01DEC2003'd-275
> or IT.date='01DEC2003'd-303
> or IT.date='01DEC2003'd-334
> or IT.date='01DEC2003'd-365)
> order by IM.Area, IT.itemid, IT.date desc;
> quit;
>
> Captain

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
1
by: Brian Jorgenson | last post by:
I am looking for a formula to put in my query to pull data based on the last 3 months. It starts with the current day and will go back 3 months. Here is my wrkflow language for example: ...
2
by: Mary | last post by:
I am trying to develop a query which will determine the average costs using a rolling average of the past 12 months of data. In other words, if I entered the Ship Month of January and the Ship...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
1
by: DJo | last post by:
I am trying to insert a set of date variables to use in a stored proc that will automatically select the last 12 running months worth of data grouped monthly. This code stops at the end of the prior...
2
by: sixstringsk | last post by:
Can anyone here help me with this... I have a date code to display the date 7 days in the future— check it out here : http://hidefsounds.com/date.html The problem is that the day of the month...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
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...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.