Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Date of This Past Sunday 2

Status
Not open for further replies.

Jesus4u

Programmer
Feb 15, 2001
110
0
0
US
Please help. This is my code. It brings back nothing. But if I hard code the date as '03/28/2004' it works!

declare @sBeginSunday smalldatetime
set @sBeginSunday = GetDate()-@@DateFirst+1
print @sBeginSunday

SELECT * FROM CRM_MDB...broadcasts
WHERE cast(AirDate as smalldatetime) = @sBeginSunday

Exams Passed: 70-152, 70-175, 70-176, 70-100
 
Try changing your code to this:
Code:
declare @sBeginSunday smalldatetime
set @sBeginSunday = GetDate()-@@DateFirst+1
print @sBeginSunday

SELECT * FROM CRM_MDB...broadcasts
WHERE convert(char(10),AirDate,101) = convert(char(10),@sBeginSunday,101)

~Brian
 

select *
SELECT * FROM CRM_MDB...broadcasts
WHERE CONVERT(Char,AirDate,101) =

CONVERT(Char,DATEADD(day,-DatePart(weekday,GetDate())+1,GetDate()),101)


Thanks

J. Kusch
 
I prefer bdreed35's method! Just wanted to show there are usually more than one avenues to go in solving queries.

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top