ShoSom
ShoSom

Reputation: 29

How to display the name of day and then only display data from a particular day

So I have a query that displays the name of the day of the week and the wine that went with that day. The problem I have is that I only want to display data from Tuesday. How would I go about doing that?

select to_char(res_date, 'DAY'), wine from DSS_TEST;

Upvotes: 0

Views: 77

Answers (1)

Thorsten Kettner
Thorsten Kettner

Reputation: 94884

To limit your result set use a WHERE clause. You can use TO_CHAR to get the day and compare it to a literal. Only be aware of two things:

  1. The result of TO_CHAR(somedate, 'DAY') depends on the dbms' date language setting.
  2. The resulting name is padded with blanks to match the length of the widest day name in the date language.

Having said this:

select to_char(res_date, 'FMDAY'), wine 
from DSS_TEST
where to_char(res_date, 'FMDAY', 'NLS_DATE_LANGUAGE=AMERICAN') = 'TUESDAY';

Upvotes: 1

Related Questions