1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【MySQL】今日の日付の0時0分を取得する方法

Last updated at Posted at 2022-10-06

使用例

いずれのパターンも結果は同じになります

SELECT TIMESTAMP(CURDATE());
SELECT TIMESTAMP(CURRENT_DATE());
SELECT TIMESTAMP(CURRENT_DATE);

実行結果

  -> 2022-10-06 00:00:00

TIMESTAMP()の引数に日付を入れると日付時間値を返す作用を利用し、
今日の日付(2022-10-06)を変換しています。

CURDATE() 、CURRENT_DATE() 、CURRENT_DATE ではいずれも今日の日付を取得できます。
CURRENT_DATE() と CURRENT_DATE は内部的には CURDATE() を実行しているとのことです。

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?