Help us understand the problem. What is going on with this article?

TO_CHARにTO_DATEを重ねる意味

More than 1 year has passed since last update.

TO_CHARの結果に対してTO_DATE??

SQLを見ていたら以下ような文を見つけました。

TO_DATE(TO_CHAR(sysdate, 'MM/DD/YYYY'), 'MM/DD/YYYY')

最近SQLを始めたばかりなので、何のことか分からず調べて見ました。
すると、ここに解説が載っていました。

SQL> select SYSDATE mydate from dual;

MYDATE
---------
14-NOV-05

SQL> alter session set nls_date_format = 'MM/DD/YYYY';

SQL> select SYSDATE mydate from dual;

MYDATE
----------
11/14/2005

SQL> select TO_DATE(TO_CHAR(sysdate, 'MM/DD/YYYY'), 'MM/DD/YYYY') mydate from dual;

MYDATE
----------
11/14/2005

環境変数を使わずにDATEをフォーマットする方法みたいですね:relaxed:
私のようなSQL初心者が調査に困らないように記事にしました:spy:

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away