I have a problem in DataGrid

Posted by Nuwan under ASP.NET on 1/23/2012 | Points: 10 | Views : 895 | Status : [Member] | Replies : 3
HI all,

I have a SQL Table, have a three main field,
CNO Amount Date
LCKY001 1000.00 25/11/2011
LCKY001 1000.00 25/12/2011
LCKY001 2000.00 25/01/2012
LCKY002 3000.00 23/11/2011
LCKY002 2000.00 23/01/2012

Like this. I want to bind this data in DataGrid and I want to Display only Current Month Data.
CNO Amount
LCKY001 2000.00
LCKY002 2000.00

Like this. How I do that. What is the Query I want to use. Please help this matter.

Thank You.....

Rathnayake


Responses

Posted by: Blessyjees on: 1/24/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Try this

SELECT cno,amount FROM tblName WHERE [date] BETWEEN CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@currentdate)-1),@currentdate),103) AND
CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@currentdate))),DATEADD(mm,1,@currentdate)),103)

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sahoomanoj27 on: 1/24/2012 [Member] Starter | Points: 25

Up
0
Down
Select CNO,Amount from [TABLENAME] where MONTH( CONVERT(DATE,[DATE COLUMN]))=MONTH(GETDATE())

That's It.

Hope it helps

Manoj Sahoo

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 1/28/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks for your reply.............

Rathnayake

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response