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

Help with query after date columns combined.

2
Hello,

I need some help, so thanks in advance.

My database has 5 columns matching to particular years, i.e.,PrevYr, PrevYr1, PrevYr2, PrevYr3, PrevYr4.

In a simple query, I've combined all 5, to make 1 column, that would look like,

2007 2006 2003 when it outputs.

Now the problem,

I actually only want to see the Maximum year, so for the example above, for the row, just show 2007 (without the 2006 and 2003).

How can I pick out 2007, or more precisely the most current year?

Thanks!
Joe
Aug 29 '07 #1
3 1289
Scott Price
1,384 Expert 1GB
Hello,

I need some help, so thanks in advance.

My database has 5 columns matching to particular years, i.e.,PrevYr, PrevYr1, PrevYr2, PrevYr3, PrevYr4.

In a simple query, I've combined all 5, to make 1 column, that would look like,

2007 2006 2003 when it outputs.

Now the problem,

I actually only want to see the Maximum year, so for the example above, for the row, just show 2007 (without the 2006 and 2003).

How can I pick out 2007, or more precisely the most current year?

Thanks!
Joe
Hi, Joe!

You have a problem arising from an improperly designed database. Have a look at this tutorial: Database Normalisation and Table Structures

When you correctly design your table to put all years into one column, choosing the current year becomes quite simple. DMax([ColumnName]) in the query criteria grid will do the trick.

Using an abnormal design like you have makes things very hard to do (as you are finding).

Regards,
Scott
Aug 29 '07 #2
fezza1
2
Hi,

I did inherit this for what it's worth.

But the reasoning is that each Individual can have multiple years and they wanted to display that as such.

For instance:

Individual PrevYr PrevYr1 PrevYr2
ABC 2007 2006 2005

etc....


Hi, Joe!

You have a problem arising from an improperly designed database. Have a look at this tutorial: Database Normalisation and Table Structures

When you correctly design your table to put all years into one column, choosing the current year becomes quite simple. DMax([ColumnName]) in the query criteria grid will do the trick.

Using an abnormal design like you have makes things very hard to do (as you are finding).

Regards,
Scott
Aug 29 '07 #3
Scott Price
1,384 Expert 1GB
I wasn't faulting you personally, just pointing out the pitfalls of a non-normalized database! :-)

The DMax() or Max() function in the query you have already created will give you the maximum value contained in that column.

Regards,
Scott
Aug 29 '07 #4

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

Similar topics

3
by: Randell D. | last post by:
Folks, I'm working on an ecommerce website that deals with credit card expiry dates. The table has two columns for year and month. I currently have a select that says: ...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
2
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
7
by: Techhead | last post by:
I have a date/time field with a sql format of "datetime" The actual date/time data format is MM/DD/YYYY^hh:mm:ss:pm or "1/25/2007 12:00:16 AM" Both the date and time are combined on the same field...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: RussCRM | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
2
by: Dinesh | last post by:
Hi experts, I am working on SQL Server 2005. Now i have to write a query which will extract some information from a table. My main table is having few columns supose 3 columns. EmpID ...
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...
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
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
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...
0
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.