[dba-SQLServer] SQL Server date functions

jwcolby jwcolby at colbyconsulting.com
Tue Mar 18 13:41:13 CDT 2008


Cool, thanks! 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Tuesday, March 18, 2008 2:31 PM
To: Discussion concerning MS SQL Server
Subject: Re: [dba-SQLServer] SQL Server date functions

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
>
>
_______________________________________________
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