[dba-SQLServer] SQL Server date functions

Arthur Fuller fuller.artful at gmail.com
Tue Mar 18 13:30:47 CDT 2008


Here you go, JC.

<code>
CREATE FUNCTION [dbo].[fn_JustDate]
  ( @date datetime )
RETURNS varchar(10)
AS
BEGIN
  RETURN ( CONVERT(varchar(10), at date,101) )
END
</code>

Call it in your Where clause, passing the date column in question and
presto.
Arthur

On 3/18/08, jwcolby <jwcolby at colbyconsulting.com> wrote:
>
> I am pulling a TopN kind of thing and marking those records with GetDate()
> which places a date and time in a date field.  Now I want to pull all the
> records with today's date.  The first problem is that GetDate() pulls the
> date and time.  The second problem is what to place in the filter.  I am
> not
> finding a date() kind of thing like you have with Access.
>
> How do I pull all records with today's date in a date field (that also
> contains the time)?
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>



More information about the dba-SQLServer mailing list