SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Last Date of the month
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jim_jim
Constraint Violating Yak Guru

USA
302 Posts

Posted - 04/26/2013 :  12:21:38  Show Profile  Reply with Quote
Hi All
I would like to write a query that will return all requests from Customer_infor table where the eligthrudate is someday between the month and not first and last day of the month

Sample Data
requestid EligThruDate
218584 12/27/12
221328 09/01/10
221340 12/31/09
221355 07/24/12


My query should not return becasue the eligthrudates are on the first or last day of the month and any other requests with other dates should be ignored

221328 09/01/10

221340 12/31/09


Need help

thanks

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 04/26/2013 :  12:42:23  Show Profile  Reply with Quote
Please put your data in a consumable format so you can run queries against it. Here is one (poor) solution:
DECLARE @Foo TABlE (requestid int, EligThruDate DATE)

INSERT @Foo VALUES
(218584, '12/27/12'),
(221328, '09/01/10'),
(221340, '12/31/09'),
(221355, '07/24/12')


SELECT *
FROM @Foo
WHERE 
	MONTH(EligThruDate) = MONTH(DATEADD(DAY, -1, EligThruDate))
	AND MONTH(EligThruDate) = MONTH(DATEADD(DAY, 1, EligThruDate))
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

USA
302 Posts

Posted - 04/26/2013 :  14:46:17  Show Profile  Reply with Quote
Sorry and thank You
quote:
Originally posted by Lamprey

Please put your data in a consumable format so you can run queries against it. Here is one (poor) solution:
DECLARE @Foo TABlE (requestid int, EligThruDate DATE)

INSERT @Foo VALUES
(218584, '12/27/12'),
(221328, '09/01/10'),
(221340, '12/31/09'),
(221355, '07/24/12')


SELECT *
FROM @Foo
WHERE 
	MONTH(EligThruDate) = MONTH(DATEADD(DAY, -1, EligThruDate))
	AND MONTH(EligThruDate) = MONTH(DATEADD(DAY, 1, EligThruDate))


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000