Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Problem with dates etc

Author  Topic 

jonclayIRM
Starting Member

12 Posts

Posted - 2015-02-26 : 08:34:09
Hi there

I'm sure this is a very simple issue but I can't seem to get my head around it, and I wondered if anyone could please help?

I'm using the following script, but instead of pulling out only user WEB it's pulling out others too and it completely ignoring my dates by pulling out records with lower dates.

SELECT ContactID, AddressType, Address1, Address2, Address3, Town, County, Postcode,
Telephone1, Telephone2, Fax, DateCreated, UserCreated, DateAmended, UserAmended
FROM dbo.Addresses
WHERE
DateCreated >'01/01/2015' OR DateAmended >'01/01/2015'
AND UserCreated='WEB' OR UserAmended='WEB'
ORDER BY UserCreated, DateCreated, UserAmended, DateAmended

Many thanks
Jon

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2015-02-26 : 08:56:07
WHERE
(DateCreated >'20150101' OR DateAmended >'20150101')
AND
(UserCreated='WEB' OR UserAmended='WEB')


Too old to Rock'n'Roll too young to die.
Go to Top of Page

jonclayIRM
Starting Member

12 Posts

Posted - 2015-02-26 : 08:58:57
Wow.... that easy eh?!

Thank you SO SO much!!

Best wishes
Jon
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2015-02-27 : 15:23:34
:)
welcome


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -