search records by date

  • Thread starter Emanuel Violante
  • Start date
E

Emanuel Violante

Hi everyone,

I Have the following structure table:

YEAR | MONTH | 1 | 2 | 3 | 4 | 5 |........| 29 | 30 | 31 |
-----------------------------------------------------------------
2009 | 10 | 5 | 0 | 6 |

What i need is to filter by date, for example by clicking in a command
button, i woul like to obtain the value of current day, for example, the 3rd
October, i would like to click in a button and get the value 6

--
Thanks,

Sorry if my english isn''t correct, but I''m from Potugal ;)

Emanuel Violante Galeano
 
D

Douglas J. Steele

Sorry, but your table is incorrectly designed.

Your data should be stored as

YEAR | MONTH | DAY | VALUE
 
E

Emanuel Violante

Tks for your reply,

I know that this is not the perfect structure, but the table is from our
gestion software, and i have it linked by an ODBC connection, and i can't
change the structure, any idea about how can i possible do it?
--
Thanks,

Sorry if my english isn''t correct, but I''m from Potugal ;)

Emanuel Violante Galeano
 
D

Douglas J. Steele

Do you need to be able to update the table, or just view it?

If all you need is to view it, try creating a UNION query to normalize the
data:

SELECT [Year], [Month], 1 AS [Day], [1] AS [Value]
FROM MyTable
UNION
SELECT [Year], [Month], 2 AS [Day], [2] AS [Value]
FROM MyTable
UNION
SELECT [Year], [Month], 3 AS [Day], [3] AS [Value]
FROM MyTable
UNION
....
UNION
SELECT [Year], [Month], 31 AS [Day], [31] AS [Value]
FROM MyTable

(Note that all of the field names above should be changed: they're all
reserved words. For a comprehensive list of names to avoid, as well as a
link to a free utility to check your application for compliance, see what
Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top