Thursday, July 14, 2011

SqlServer date functions

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755

Example:
select 
 distinct PLANT_ID, 
 userid,
 update_id,
 convert(varchar(10),dateadd(dd,datediff(dd,0,updateDate_Stamp),0),101) 
  as PO_date
from inventory..inv_log
where plant_id = 'HR' 
 and type = 'T' 
 and updateDate_Stamp > '05/01/2011' 
 and userID like '%SLAM%'
order by 1,2,3