|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple SQL syntax question ??Dear all,
I have a store procedure which has as input parameter @MonthId (integer) Then in my database table I have a dateTime field. Then I need to exctract records where the Month part of the DataTime field correspond to @MonthId parameter. How to do that ? regards serge declare @monthID int
set @monthid = 12 select * from tablenameWHERE MONTH(DataTime) = @MonthID -- Show quoteHTH. Ryan "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in message news:257EC920-F058-4516-BF08-85F9E109374D@microsoft.com... > Dear all, > > I have a store procedure which has as input parameter @MonthId (integer) > > Then in my database table I have a dateTime field. Then I need to exctract > records where the Month part of the DataTime field correspond to @MonthId > parameter. > > How to do that ? > > regards > serge Thnaks guys for your reply...
Sometimes looks so easy... sorry I am not specialist in sql syntax regards serge Show quote "Ryan" wrote: > declare @monthID int > set @monthid = 12 > > select * from tablenameWHERE MONTH(DataTime) = @MonthID > > -- > HTH. Ryan > > > "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in > message news:257EC920-F058-4516-BF08-85F9E109374D@microsoft.com... > > Dear all, > > > > I have a store procedure which has as input parameter @MonthId (integer) > > > > Then in my database table I have a dateTime field. Then I need to exctract > > records where the Month part of the DataTime field correspond to @MonthId > > parameter. > > > > How to do that ? > > > > regards > > serge > > > add in the where clause:
where month(<table_field>) = @MonthId -- Show quoteCurrent location: Alicante (ES) "serge calderara" wrote: > Dear all, > > I have a store procedure which has as input parameter @MonthId (integer) > > Then in my database table I have a dateTime field. Then I need to exctract > records where the Month part of the DataTime field correspond to @MonthId > parameter. > > How to do that ? > > regards > serge |
|||||||||||||||||||||||