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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-12 : 13:44:58
|
| I want to get current date minus flg_cdt > 300 select cossn, count(fo) as PendinginFOfrom t16pendall where flg_cdt > dateadd(dd, -300, getdate())group by cossnHere's the table and some data to go inside the table.Thanks.[dbo].[T16pendall]( [COSSN] [char](11) NOT NULL, [FLG_CDT] [datetime] NOT NULL, [FO] [varchar](3) NOT NULL) ON [PRIMARY]insert into T16Pendallselect '1259798j733', 04/05/2006 '200' union all select '5259478j745', 04/05/2004 '200' union all select '7239798j787', 02/05/2004' 420' union all select '8255798j747', 02/05/2010' 520' union all select '9259768j765', 04/05/2002' a48' union all select '1259748j766', 10/05/2010' a48' union all select '1959798j771', 10/05/2010' a48' union all select '1059798j780', 06/05/2009' 600' union all select '1359798j713', 09/05/2009 '600' union all select '1159798j741', 09/05/2009 '600' union all select '1756798j765', 02/05/2010 '800' union all select '1469798j765', 10/05/2009 '200' union all select '1357798j765', 10/05/2008' 200' |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-12 : 13:54:31
|
| Yes it works I just want me make sure the < or > is the correct way so I can get my data.I care about the datetime portion as I'm just getting counts. Does that matter? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-12 : 14:16:19
|
| Thanks I got the same results with that one as well. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2010-10-12 : 17:05:29
|
| SQL Server supports ANSI/ISO Standard DATE data types and CURRENT_TIMESTAMP; you do not have to write 25+ year old dialect any more.--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|
|