December 16, 2009 at 8:45 am
I want to select the last 60 days transactions from current date. please help how to select?
December 16, 2009 at 8:47 am
use DATEADD function
SELECT DATEADD(d,-60,GETDATE())
December 16, 2009 at 8:50 am
I need to select the txs by Day wise
like
d1 d2 ------d60
p1 - - ----- -
p2 - - ------- -
The format could be same as above
December 16, 2009 at 8:54 am
That is not really clear,
you did not mention p1 d1 d2 originally so i do not know what they mean..
can you post your table definitions, sample data and your expected results?
December 16, 2009 at 8:55 am
as mentioned above it's not very clear what you are trying to achieve. This may help:
http://www.sqlservercentral.com/Forums/Topic825668-338-1.aspx#bm826044
December 16, 2009 at 8:58 am
Today is 16th Dec so i need to get the txs count day wise(i.e Oct'15 to Dec'15)
like For program1 from oct15 to Dec'15 day wise i need to display the transaction count
Oct15 Oct16 Oct17 .........................Dec'15
program1
Please let me know is that fine
December 16, 2009 at 9:03 am
Looks like selecting 60 days of data and a pivot to boot. Am I correct?
December 16, 2009 at 9:03 am
What version of SQL Server are you using?
December 16, 2009 at 9:04 am
That shouldn't be a problem to produce those results use a SELECT with a GROUP BY and a WHERE clause with the DATEADD function.
If you would like some exact code to run, then you are going to have to provide some sample data to work from otherwise it is all guess work from our side.
have a look at this link on how to get the best responses
http://www.sqlservercentral.com/articles/Best+Practices/61537/
December 16, 2009 at 9:04 am
SQL server 2005
December 16, 2009 at 10:41 am
How about my other question??
December 17, 2009 at 12:10 am
yes..60 days of data on day wise and i am using SQL server 2005
December 18, 2009 at 5:12 pm
It sounds like you want transactions going back two months back and not 60 days back so that the days of the month match. i.e. 14th to 14th.
Try the below.
SELECT *
FROM table
WHERE TransactionDate >= DateAdd(m,-2,GetDate())
December 18, 2009 at 7:43 pm
purushotham.k9 (12/17/2009)
yes..60 days of data on day wise and i am using SQL server 2005
Please see the following... it'll do what you want. You will have to spend a bit of time training yourself on it though it does have step-by-step instructions.
http://www.sqlservercentral.com/articles/Crosstab/65048/
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply