Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT datename(DAY,trandate) as Months,SUM(TOTALMARGIN) AS TOTALMARGIN,SUM(AVAILABLEMARGIN) AS TOTAVLBMARG
INTO #DAYWISECLIENTMARGIN
FROM tableA
WHERE 
TRANDATE BETWEEN 'apr 1 2012' AND 'APR 30 2012 23:59'
group by  datename(DAY,trandate)
ORDER BY datename(DAY,trandate)

output
=========================
date   TOTALMARGIN  TOTAVLBMARG
1       100000        10000

2        2000          30000

I want to output should contained month day year separate like
date month year  totalmargin   totalavlbal



kindly help...
Posted
Updated 9-Feb-15 1:12am
v2

1 solution

Try this example and adapt:
SELECT DATEPART(year, getdate()), DATEPART(month, getdate()), DATEPART(day, getdate());

refer: DATEPART[^]
Or
DATENAME[^]
 
Share this answer
 
v2
Comments
deeptul 9-Feb-15 7:28am    
thanks its done
Peter Leow 11-Feb-15 6:15am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900