| Author |
Topic  |
|
|
tt350z
Starting Member
5 Posts |
Posted - 03/13/2013 : 10:48:19
|
Hello Gentleman,
I am drawing a blank and I was wondering if anyone could help, I am trying to write a query that picks two dates or to make it easier say the last 60 days from current date and put a value of 1 if its true and 0 if not so example today is 3/13/2013 so I need everything for last 60 days and tomorrow when query runs again it should add one day +1 and drop the last day. Hopefully that's clear it not I can try to again :)
THANK YOU!!!!! |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 03/13/2013 : 11:03:01
|
do you've a calendar table?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
tt350z
Starting Member
5 Posts |
Posted - 03/13/2013 : 11:10:43
|
| Yes I do - To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD') |
 |
|
|
tt350z
Starting Member
5 Posts |
Posted - 03/13/2013 : 11:13:00
|
quote: Originally posted by tt350z
Yes I do - To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD')
Its the daily transactions that get stored in that format. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 03/13/2013 : 11:21:22
|
i'm asking on table not on column
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
tt350z
Starting Member
5 Posts |
Posted - 03/13/2013 : 11:34:52
|
ohh sorry actual date table no and I cant add one...its a 3rd party database.
select * from yourTable where [Date] <= dateadd(day,-60, cast(getdate() as date)) -- assuming you're using SQL 2008 This will select all older dates.
If you need to select last 2 months, then change your condition this way
select * from YourTable where [Date]>=dateadd(day,-60, cast(getdate() as date)
but it doesnt like the dateadd function.
this is the only date I have access too To_Char(INFORMENT.PRODUCT_OFFER_PURCHASE.DATE_ADDED, 'YYYYMMDD'), |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 03/13/2013 : 11:54:25
|
To_char? are you using Oracle? if yes, then you're in wrong forum. This is ms sql server forum so solutions posted here may not work well in oracle. You may be better off trying your luck in some oracle forums like www.orafaq.com in that case
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
tt350z
Starting Member
5 Posts |
Posted - 03/13/2013 : 12:00:38
|
| Its SQL& oracle but ill give that a try thanks lot :) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 03/13/2013 : 12:44:06
|
Oracle SQL is syntactically different from T-SQL of sql server
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47189 Posts |
Posted - 03/13/2013 : 12:44:07
|
Oracle SQL is syntactically different from T-SQL of sql server
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|