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 |
whitmoj
Yak Posting Veteran
68 Posts |
Posted - 2008-10-28 : 10:32:42
|
I currently populate a tbl with the current months figures using the following date rangeWHERE DATEADD(mm,DATEDIFF(mm,0,[Date]),0)=DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)I have tried evry thing to populate 2 months worth of data into this table and I dont seem to be able to get my head round the changes needed. Any help would be grateful.Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-28 : 10:41:53
|
[code]WHERE [Date]>DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)AND [Date]<DATEADD(mm,DATEDIFF(mm,0,GETDATE())+2,0)[/code] |
 |
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-10-28 : 10:44:49
|
OrWHERE DATEDIFF(mm,[DATE],GETDATE()) = 2 |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-29 : 08:10:14
|
quote: Originally posted by hanbingl OrWHERE DATEDIFF(mm,[DATE],GETDATE()) = 2
Index wont be used if date column has itBetter approach is to use the approach Visakh suggestedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|