2012年5月21日 星期一

SQL condition to get record before early 15 day

Reference:
http://blog.sqlauthority.com/2007/06/21/sql-server-retrieve-current-date-time-in-sql-server-current_timestamp-getdate-fn-now/
http://www.sqlusa.com/bestpractices/datetimeconversion/

Get today function:
GETDATE()

Convert string to Date format:
CONVERT(datetime, [Field])

SQL command:
SELECT *

FROM [Table]
WHERE (GETDATE() - CONVERT(datetime, [Field])) > 15

沒有留言:

張貼留言