Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 display the records for this month

Author  Topic 

vidhya
Posting Yak Master

108 Posts

Posted - 2008-04-15 : 08:56:21
hi friends,

how to display the records for current month?

dhinasql
Posting Yak Master

195 Posts

Posted - 2008-04-15 : 09:00:16
Hi vidhya,

Please use that code what i have send to u
Go to Top of Page

vidhya
Posting Yak Master

108 Posts

Posted - 2008-04-15 : 09:01:51
You never send any code
Go to Top of Page

dhinasql
Posting Yak Master

195 Posts

Posted - 2008-04-15 : 09:05:13
SELECT *
FROM tbl_voting v,tbl_lkvotefor l
WHERE v.creationdatetime > DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate()),0))
AND v.creationdatetime <DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+2,0)) and v.deleted=0 and v.voteforid=l.voteforid
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-15 : 09:05:16
did this not give you enough of a push in the right direction to adapt it for month as well?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=100996

Em
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-15 : 09:13:27
Silver platter...
SELECT	*
FROM Table1
WHERE Col1 >= DATEADD(MONTH, DATEDIFF(MONTH, '19000101', GETDATE()), '19000101')
AND Col1 < DATEADD(MONTH, DATEDIFF(MONTH, '18991231', GETDATE()), '19000101')

I have a view where you can see all these calculations.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86769



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-15 : 09:40:36
quote:
Originally posted by vidhya

hi friends,

how to display the records for current month?



All suggestions would work fine if the datatype of the date column is DATETIME

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-15 : 09:42:48
quote:
Originally posted by dhinasql

SELECT *
FROM tbl_voting v,tbl_lkvotefor l
WHERE v.creationdatetime > DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate()),0))
AND v.creationdatetime <DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+2,0)) and v.deleted=0 and v.voteforid=l.voteforid



That wont give perfect result
Refer Peso's query

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -