I'd like a simple, reusable way to select the date (without the time) from the server. I thought I would create a function as shown in the code window.
But the create statement throws these errors:
Msg 102, Level 15, State 1, Procedure DateFromServer, Line 3
Incorrect syntax near 'RETURNS'.
Msg 178, Level 15, State 1, Procedure DateFromServer, Line 8
A RETURN statement with a return value cannot be used in this context.
Any ideas how to fix this simple function coding error? And/or another way to accomplish what I'm trying to accomplish?
SET ANSI_NULLS OFF
SET QUOTED_IDENTIFIER OFF
CREATE FUNCTION [dbo].[DateFromServer]
DECLARE @dat char(10)
set @dat = (select convert(char(10), getdate(),101))