473,394 Members | 1,817 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.

Querying 1 Day Old Data ( Date )

My table looks like the following

[PartNumber], [FromStep],[ToStep],[MovedDateValue]
Ex.
[Fish], [Step1], [Step2],[1/2/2007]
[Fish[, [Step2], [Step3],[1/3/2007]

It contains all the [FromStep] and [ToStep] that [PartNumber] goes through in the past 3 months.

How would I go about querying for all [PartNumber]'s that took more than 1 day to move from Step 1 to Step 2?... so on and so forth.

I tried the DateDiff Function and the numbers did not work.
Jan 10 '08 #1
3 1338
FishVal
2,653 Expert 2GB
Hi, there.

You may try to join the table with itself on records where [PartNumber] is the same and [ToStep] in one table alias is the same as [FromStep] in another. Thus you will obtain dataset with records containing dates of sequential steps, then you may use DateDiff() function. Or you may include day difference in JOIN criteria.

Something like this.

Expand|Select|Wrap|Line Numbers
  1. SELECT t1.[PartNumber], t1.[MovedDateValue], t2.[MovedDateValue] FROM [YourTableName] AS t1 INNER JOIN [YourTableName] AS t2 ON t1.[PartNumber]=t2.[PartNumber] AND t1.[ToStep]=t2.[FromStep] AND DateDiff("d", t1.[MovedDateValue], t2.[MovedDateValue]) > 1;
  2.  
Regards,
Fish
Jan 10 '08 #2
If I only had half the smarts you did!
That seem to do the trick. Thanks.

Now if I add:

WHERE t1.[to_order_step_num]="Step1";

To the end, I will be able to search specific steps that are =>1, correct?
Jan 10 '08 #3
FishVal
2,653 Expert 2GB
If I only had half the smarts you did!
That seem to do the trick. Thanks.

Now if I add:

WHERE t1.[to_order_step_num]="Step1";

To the end, I will be able to search specific steps that are =>1, correct?
If you ever have records where [ToStep]="Step1", then you will get records for Step1->Step2 movements.
Jan 10 '08 #4

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

Similar topics

3
by: Keith | last post by:
I am fairly new to SQL so sorry if this is a really dumb question. I have a small (still) SQL database, which I am trying to query from an ASP page. The field I am querying is of DATETIME data...
7
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r =...
7
by: ndn_24_7 | last post by:
Hello all, I'm trying to run a query to make a report. My database is a incident reporting database. I'm tryng to make a monthy report for incidents. The field I need to query in the date field...
6
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about...
3
by: AndyBell | last post by:
Hi all! I have an Access 2000 database for the Habiat for Humanity where I work. This is the second database I have written and it gets a bit more complex each time... I have learned much and...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
0
by: roiavidan | last post by:
Hi, I'm having a bit of a problem with a small application I wrote in C#, which uses an Access database (mdb file) for storing financial data. After looking for a similiar topic and failing to...
2
by: Steven Cheng [MSFT] | last post by:
Hi Cj, I also noticed that the "Act" variable here seems hasn't been declared(or declared anywhere else?). I've try building the same code and got the same result and the "Operator '+' cannot be...
4
by: mcmahon | last post by:
Hi, I have a MS Access DB with a query that I need to display in vb but am not too sure on how to go about it. The query has some criteria - i.e you have to input a date to run the query. I think...
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:
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...
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
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
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
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...
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...

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.