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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Date and Time Column question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

phate06
Starting Member

17 Posts

Posted - 05/24/2013 :  09:33:00  Show Profile  Reply with Quote
Hi there,

First time poster here so please be gentle

I have a basic query that I would like to display orders that have been ameneded. I do however need it to display results from today only, so in the software we user it will show a real time result of the query (clicking refresh in the software would do this)

The column is in a date time format e.g 2013-05-24 00:00:00 - I don;t seem to be able to get the desired results - below is the script minus the part in the where clause that I require.

Can anyone assist

select
OH.OrderID,
OH.Deleted,
C.Name as 'Customer Name',
OH.OrderNumber,
OH.DateTimeLastModified
from OrderHeader OH
inner join Customer C with (NOLOCK) on C.CustomerID=OH.CustomerID
where OH.DateTimeLastModified = ????
and OrderType=1
order by DateTimeLastModified asc

Thanks

bandi
Flowing Fount of Yak Knowledge

India
2210 Posts

Posted - 05/24/2013 :  09:37:46  Show Profile  Reply with Quote
-- Do like this....
WHERE DateTimeLastModified >= DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)
AND DateTimeLastModified < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)


Refer this link for different approaches
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html

--
Chandu
Go to Top of Page

phate06
Starting Member

17 Posts

Posted - 05/24/2013 :  09:46:18  Show Profile  Reply with Quote
Thank you so much - and thank you for the quick response - much appreciated
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2210 Posts

Posted - 05/27/2013 :  00:30:01  Show Profile  Reply with Quote
quote:
Originally posted by phate06

Thank you so much - and thank you for the quick response - much appreciated


welcome

--
Chandu
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