Reputation: 119
I am using following query
select month(datee) as [Month], year(datee) as [Year]
from ledger_broker
group by month(datee),year(datee)
Output :
What's the query to combine both columns and show as
1-2016
2-2016
OR
Jan-2016
Feb-2016
Upvotes: 0
Views: 268
Reputation: 97101
Use a Format()
expression to format the month plus year as you wish. For months as digits, this should work:
SELECT DISTINCT Format(datee, 'm-yyyy') AS month_year
FROM ledger_broker
ORDER BY Month(datee), Year(datee);
For abbreviated month names, adjust the Format
pattern:
SELECT DISTINCT Format(datee, 'mmm-yyyy') AS month_year
Upvotes: 2