1
1

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 5 years have passed since last update.

【MySQL】date型の文字列結合

1
Posted at

date型のカラムをconcatを使って結合する場合、そのままだとうまくいかないので、char型にキャストしてから行う。

文字列結合する例
SELECT concat(cast(date_col as char),' 12:00:00') FROM foo;
//=>2015-05-31 12:00:00

そのまま、concatして失敗する例。

失敗例
SELECT concat(date_col,' 12:00:00') FROM foo;
//=>323031352d30352d33312031323a30303a3030

参考:stackoverflowの記事

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?