Divyam Solanki February 2016

Sort Month+Year in VB.net using MS-ACCESS as db

I am using following query

select month(datee) as [Month], year(datee) as [Year]
from ledger_broker
group by month(datee),year(datee)

Output : Output

What's the query to combine both columns and show as

1-2016
2-2016

OR

Jan-2016
Feb-2016

Answers


HansUp February 2016

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

Post Status

Asked in February 2016
Viewed 3,339 times
Voted 8
Answered 1 times

Search




Leave an answer