Please help me format the day of week using Transact-SQL

  • Thread starter Mitchell_Collen via AccessMonster.com
  • Start date
M

Mitchell_Collen via AccessMonster.com

Hi all.
I have create a form with a chart that pulls data from an aggregated view.
The the values are grouped by day of week. For instance, 1,2,3,4,5,6,7 The
problem is that that I need it to only read as mon, tue,wed, thur, fri ,sat,
sun

Is there a way to format the dates like this in a chart form by using
transact - sql?

here is my view:

SELECT Station, COUNT(TxDatetime) AS Total, DAY(TxDatetime) AS Day,
PaType
FROM dbo.phmPYXHx
WHERE (TxDatetime >= { fn NOW() } - 8) AND (PaType IN (N'LOADED',
N'REFILLED', N'RESTOCKED'))
GROUP BY Station, DAY(TxDatetime), PaType


Thanks in advance! Misty
 
S

Sylvain Lafontaine

Use the Case Statement:

Select ... Case DAY(TxDatetime)
when 1 then N'mon'
when 2 then N'tue'
when 3 then N'wed'
when 4 then N'thur'
when 5 then N'fri'
when 6 then N'sat'
when 7 then N'sun'
End as DayOfWeek, ....

Also, this kind of question would be best answered in a newsgroup dedicated
to T-SQL such as microsoft.public.sqlserver.programming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top