Pro Tip : SQL Tips

Calling a udf from SQL Query Analyser
SELECT dbo.udf_calculate_working_days(’01/01/2000′, ’01/01/2001′)

Calling a Table valued function from SQL Query Analyser
SELECT * from dbo.udf_calculate_working_days(’01/01/2000′, ’01/01/2001′)

Get the number of days between 2 dates
SELECT DATEDIFF(dd, ’01/01/2009′ , ’01/01/2010′) as ‘total_days’

SQL for when checking against todays date
SELECT DATEADD(dd, DATEDIFF(dd,0,@order_date), 0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s