Home All Groups Group Topic Archive Search About

Simple SQL syntax question ??

Author
23 Mar 2006 8:55 AM
serge calderara
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

Author
23 Mar 2006 9:08 AM
Ryan
declare @monthID int
set @monthid = 12

select * from tablenameWHERE MONTH(DataTime) = @MonthID

--
HTH. Ryan


Show quote
"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
Author
23 Mar 2006 10:43 AM
serge calderara
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
>
>
>
Author
23 Mar 2006 9:12 AM
Enric
add in the where clause:
where month(<table_field>) = @MonthId
--
Current location: Alicante (ES)


Show quote
"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

AddThis Social Bookmark Button