date month queries in MSQL

date month queries in MSQL

Post by sd » Fri, 16 Mar 2001 01:03:49



I have a birthday field and I try to do a query only on month and day date.
Is there a SQL function allowing to have the month and the day from a date ?

thanks.

severine

 
 
 

date month queries in MSQL

Post by Dan Guzma » Fri, 16 Mar 2001 00:23:08


Check out the DATEPART function in the Books Online.

Hope this helps.

-----------------------
SQL FAQ links (courtesy  Neil Pike):

 http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
 (faqxxx.zip in lib 7)
 or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
 or www.sqlserverfaq.com
 or www.mssqlserver.com/faq
-----------------------


Quote:> I have a birthday field and I try to do a query only on month and day
date.
> Is there a SQL function allowing to have the month and the day from a date
?

> thanks.

> severine


 
 
 

date month queries in MSQL

Post by BP Margoli » Fri, 16 Mar 2001 00:39:10


Severine,

use pubs
go

select *
from sales
where convert(char(10), ord_date, 101) like '09/14%'

------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


Quote:> I have a birthday field and I try to do a query only on month and day
date.
> Is there a SQL function allowing to have the month and the day from a date
?

> thanks.

> severine

 
 
 

date month queries in MSQL

Post by Gilbert Widme » Fri, 16 Mar 2001 02:11:12


yes , msql have difference datefunction

datediff, dateadd, datepart, datename and getdate

this funktion are descripted in the online manual

to check for a birthday

select * from yourtable
where datediff(day, birthday, 20 ) = 0
  and datediif(month, birthday, 3) = 0

this should be work

sd schrieb:

Quote:

> I have a birthday field and I try to do a query only on month and day date.
> Is there a SQL function allowing to have the month and the day from a date ?

> thanks.

> severine

--
Strawberry AG                   Gilbert Widmer