| Author |
Topic |
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2007-05-29 : 03:58:01
|
| I have a table with three fileds1 - SmsTime (datatype = datetime)2 - MsgCnt (datatype = int)3 - Message (datatype = varchar)Here MsgCnt means it will give the number of sms part (70 charector is equal to One SMS).So in each row MsgCnt may be vary. Some time it may be 1 or 3 or 5 or 2 etc.Now here I need to count how many MsgCnt is received on Today. Its not to count the rows but counting the MsgCnt fild value.Is there any sql way to find it. Plesase help me! |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-29 : 04:02:28
|
| [code]Select sum(MsgCnt)From TableWhere SmsTime = getdate()[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-29 : 04:10:03
|
Harsh,SmsTime = getdate() ? KH |
 |
|
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2007-05-29 : 04:26:41
|
Thanks harsh_athalye,Its working fine.quote: Originally posted by harsh_athalye
Select sum(MsgCnt)From TableWhere SmsTime = getdate() Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-29 : 04:31:40
|
quote: Originally posted by shajimanjeri Thanks harsh_athalye,Its working fine.quote: Originally posted by harsh_athalye
Select sum(MsgCnt)From TableWhere SmsTime = getdate() Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Are you sure you are getting any result with that ? getdate() will return the current date and time. How can you get any result with SmsTime = current date & time ?Select sum(MsgCnt)From TableWhere SmsTime = dateadd(day, datediff(day, 0, getdate()), 0) KH |
 |
|
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2007-05-29 : 09:31:31
|
| That I did some modifications..regards |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-29 : 09:38:20
|
quote: Originally posted by shajimanjeri That I did some modifications..regards
Good for you KH |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-29 : 09:47:05
|
quote: Originally posted by shajimanjeri That I did some modifications..regards
By modifications, you don't mean you used CONVERT() to truncate time part, do you?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-29 : 23:55:43
|
<<By modifications, you don't mean you used CONVERT() to truncate time part, do you?>>Most probably yes MadhivananFailing to plan is Planning to fail |
 |
|
|
|