我如何找到一周中的哪一天?

时间:2021-01-19 20:19:37

What is the name of the last day of the month of April, 2008?

2008年4月最后一天的名字是什么?

How do I do this? This isn't from a table. Do I use TO_CHAR, SYSDATE, what?

我该怎么做呢?这不是表格。我使用TO_CHAR,SYSDATE,什么?

SQL> select to_char(30-4-2008,'day') WEEKDAY from dual;

SQL> select to_char(to_date('03/30/2008','dd/mm/yyyy'), 'Dy')
  2  ;

1 个解决方案

#1


0  

You can use to_char with the format mask of fmDay (the leading fm eliminates the trailing whitespace).

您可以使用格式掩码为fmDay的to_char(前导fm消除尾随空格)。

  1* select to_char( date '2008-04-30', 'fmDay' ) from dual
SQL> /

TO_CHAR(D
---------
Wednesday

This will return the name of the day in the current session's NLS settings (i.e. Wednesday if the session is using English, something else if the NLS settings are different). You can pass additional parameters to to_char if you want to force the name of the day to be in English regardless of the session's NLS settings.

这将返回当前会话的NLS设置中的当天名称(即如果会话使用英语则为星期三,如果NLS设置不同则返回其他内容)。如果要强制使用英语的名称,无论会话的NLS设置如何,您都可以将其他参数传递给to_char。

#1


0  

You can use to_char with the format mask of fmDay (the leading fm eliminates the trailing whitespace).

您可以使用格式掩码为fmDay的to_char(前导fm消除尾随空格)。

  1* select to_char( date '2008-04-30', 'fmDay' ) from dual
SQL> /

TO_CHAR(D
---------
Wednesday

This will return the name of the day in the current session's NLS settings (i.e. Wednesday if the session is using English, something else if the NLS settings are different). You can pass additional parameters to to_char if you want to force the name of the day to be in English regardless of the session's NLS settings.

这将返回当前会话的NLS设置中的当天名称(即如果会话使用英语则为星期三,如果NLS设置不同则返回其他内容)。如果要强制使用英语的名称,无论会话的NLS设置如何,您都可以将其他参数传递给to_char。