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

Delete date values if not MAX date

I have a set of data that has two dates for each row.
The second set of dates is repetitive in some cases.
I only want the last(MAX) date retained for this second set of dates.
The raw data shows:
ID Date1 Date2
312 1/12/2013 1/18/2013
312 1/12/2013 1/29/2013
312 1/21/2013 1/29/2013
312 1/25/2013 1/29/2013
312 1/21/2013 2/20/2013
312 1/25/2013 2/20/2013

The results should be:
ID Date1 Date2
312 1/12/2013 1/18/2013
312 1/12/2013
312 1/21/2013
312 1/25/2013 1/29/2013
312 1/21/2013
312 1/25/2013 2/20/2013

Any thoughts?
Apr 17 '14 #1

✓ answered by kimomakano

Thanks Rabbit,
But it is not working for me, I forgot to clarify that this is only a subset of the data. There are multiple values for ID as well.
When I return the max of date1, grouped by date2 I lose some of the values for date1, I don't want that.

4 1348
Rabbit
12,516 Expert Mod 8TB
Create a query that returns the max of date 1 grouping by date 2. You can then outer join that back to the table to find the ones that aren't the max.
Apr 17 '14 #2
Thanks Rabbit,
But it is not working for me, I forgot to clarify that this is only a subset of the data. There are multiple values for ID as well.
When I return the max of date1, grouped by date2 I lose some of the values for date1, I don't want that.
Apr 17 '14 #3
Rabbit
12,516 Expert Mod 8TB
Then group by ID as well. You're supposed to lose some of the values for Date 1, that's the whole point, to only leave the values you want to keep. The last part of my post, where you join it back to the table is where you get the rest of the data.
Apr 17 '14 #4
ck9663
2,878 Expert 2GB
If it's the last date, why did 1/18 was returned being the earlier date. Why 1/21 returned blank? Why are there two dates for 1/25? The requested output does not make sense to me.


~~ CK
Apr 26 '14 #5

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

Similar topics

16
by: Tim Davidge | last post by:
Hi folks, been a while since I have posted a plea for help and I think I have forgotten everything I learnt from the helpful contributors to this newsgroup, that said however : I'm trying to...
1
by: Uli | last post by:
Hi, A collegue of mine has made an access entry field and keyed in all the data. Now I have to key in the same data in the same database. However, I first need to delete the values in several...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
1
by: Olaf Rabbachin | last post by:
Hi folks, I have a table in an Access-DB that has a date-field (date + time). I'd like to use a DataSet + DataGrid to achieve a grouped/hierarchical display where the user would work his/her way...
5
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one...
7
by: Shani Aulakh | last post by:
Hi there, I have a FolderWatcher.cs class that will monitor a given folder and delete files older than X number of days. I have the following methods. I need to add/show delete mothod using date...
4
by: azura | last post by:
hello sir... i had a problem... how can i delete two values?? before this i delete in one value only and it's work.. but how can i delete if i had two value...?? this is my coding for one value... ...
1
by: SEhtesham | last post by:
Hi, My application is in VS2008 coded in vb.net.I have a table with three columns FromDate,Todate and Schedule.FromDate and ToDate will have date values whereas Schedule will have a any of...
3
by: Benna | last post by:
I’m using VB.06 program. I am trying to do a check details between 2 date values records stored inside database are only start date and end date. For example, I’m searching between 2 datetime...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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.