Year only data from daily dates

  • Thread starter Thread starter Web learner
  • Start date Start date
W

Web learner

I have daily data from year 1995 to 2004. The following query
SELECT [obsDate] FROM [tblObs]
returns 3653 datevalue records for each day.

1995-01-01 00:00:00
1995-01-02 00:00:00
1995-01-03 00:00:00
----------------------
----------------------
2004-12-29 00:00:00
2004-12-30 00:00:00
2004-12-31 00:00:00

I just want a recordset having years. That means with only 10 records as
follow.

1995
1996
1997
-----
-----
2004

What should be the SQL query?

I do not know anything about objectDataSource of ADO.NET. Is it worthwhile
or better for this kind of problem?

Thanks for reading this ...

Regds,

Web learner
 
Try:

select distinct
Year (obsDate) as 'Year'
from
tblObs

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
..
I have daily data from year 1995 to 2004. The following query
SELECT [obsDate] FROM [tblObs]
returns 3653 datevalue records for each day.

1995-01-01 00:00:00
1995-01-02 00:00:00
1995-01-03 00:00:00
----------------------
----------------------
2004-12-29 00:00:00
2004-12-30 00:00:00
2004-12-31 00:00:00

I just want a recordset having years. That means with only 10 records as
follow.

1995
1996
1997
-----
-----
2004

What should be the SQL query?

I do not know anything about objectDataSource of ADO.NET. Is it worthwhile
or better for this kind of problem?

Thanks for reading this ...

Regds,

Web learner
 
Yes, it worked. This is what I wanted for the moment.

Thanks......
 

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

Back
Top