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 |
|
samsun125
Yak Posting Veteran
63 Posts |
Posted - 2009-06-18 : 08:25:09
|
| Hi all,I have one query,i need count(sal) from table from june 6th to june 2nd.declare @ed1 datetimeset @ed1=(((getdate()-1)-7)-1)print @ed1 --Jun 9 2009 5:19PMdeclare @sd1 datetimeset @sd1=((((getdate()-1)-7)-1)-7)print @sd1 --Jun 2 2009 5:19PMselect sum(sal) 'Tweets' FROM emptableWHERE date >= @sd1 and date < @ed1 and companyid=7i am getting result:711if manually i am writing query like:select sum(sal) 'Tweets' FROM emptableWHERE date between '06/02/2009 ' and '06/09/2009' and companyid=7i am getting result=856is this queries wrong why i am getting different values for same dates.if any body knows please let me know.RegardsRama. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-18 : 08:26:58
|
| Express the dates in YYYYMMDD format and seeMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-18 : 08:36:49
|
select sum(sal) AS Tweets FROM emptableWHERE date >= '20090602' and date < '20090610'and companyid = 7 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|