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.
| 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 |
 |
|
|
vidhya
Posting Yak Master
108 Posts |
Posted - 2008-04-15 : 09:01:51
|
| You never send any code |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-04-15 : 09:05:13
|
| SELECT *FROM tbl_voting v,tbl_lkvotefor lWHERE 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 |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-15 : 09:13:27
|
Silver platter...SELECT *FROM Table1WHERE 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" |
 |
|
|
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 MadhivananFailing to plan is Planning to fail |
 |
|
|
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 lWHERE 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 resultRefer Peso's queryMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|