Groups | Blog | Home
all groups > sql server programming > august 2003 >

sql server programming : sql for end-month data extracting


Gennady Besfamilny
8/1/2003 10:06:02 PM
Hello,
in my table I have 2 columns:
1. "datadate" which has format "yyyy-mm-dd" and contains daily dates for 3
years.
2 . "data" - contains daily data.

I need SQL statement to extract only end-month data like this:
2000-01-31 200
2000-02-28 100
2000-03-31 300
.........................................
2003-06-30 150

Thanks,
GB

Gennady Besfamilny
8/1/2003 11:13:11 PM
Thank you, it works in general but I still have a problem
with dates which are non- business days - for weekends I don't have data
values.
For example, I don't have value for 2003-05-31 but I do have value for
2003-05-30.
How can I modify your query to fix this problem?

Thanks,
GB


[quoted text, click to view]

David Portas
8/1/2003 11:26:51 PM
Assuming datadate is a DATETIME column:

SELECT *
FROM Sometable
WHERE MONTH(DATEADD(DAY,1,datadate))>MONTH(datadate)

--
David Portas
------------
Please reply only to the newsgroup
--

[quoted text, click to view]

AddThis Social Bookmark Button