{"id":1082,"date":"2015-12-25T10:09:03","date_gmt":"2015-12-25T01:09:03","guid":{"rendered":"http:\/\/www.dbsheetclient.jp\/blog\/?p=1082"},"modified":"2018-06-27T15:59:04","modified_gmt":"2018-06-27T06:59:04","slug":"datefromparts-datetime2fromparts%e9%96%a2%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.dbsheetclient.jp\/blog\/?p=1082","title":{"rendered":"DATEFROMPARTS, DATETIME2FROMPARTS\u95a2\u6570"},"content":{"rendered":"<p>IT\u30b3\u30fc\u30c7\u30a3\u30cd\u30fc\u30bf\u306e\u30b7\u30e5\u30a6\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/DSC_2085.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1083\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/DSC_2085-300x199.jpg\" alt=\"DSC_2085\" width=\"300\" height=\"199\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/DSC_2085-300x199.jpg 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/DSC_2085-1024x680.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4eca\u5e74\u306f\u6696\u51ac\u3068\u8a00\u308f\u308c\u3066\u304a\u308a\u3001\u30b9\u30ad\u30fc\u5834\u3067\u306f\u96ea\u4e0d\u8db3\u306e\u3068\u3053\u308d\u3082\u7d50\u69cb\u3042\u3063\u3066\u5fc3\u914d\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u6025\u306b\u5bd2\u304f\u306a\u3063\u305f\u308a\u3082\u3057\u307e\u3059\u306d\u3002\u6696\u51ac\u3068\u3044\u3046\u306e\u306f\u3001\u6696\u304b\u3044\u65e5\u304c\u7d9a\u304f\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u306a\u304f\u3001\u5e73\u5747\u3057\u3066\u6696\u304b\u3044\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3001\u5bd2\u6696\u306e\u5dee\u304c\u6fc0\u3057\u3044\u5834\u5408\u3082\u591a\u3044\u3088\u3046\u3067\u3059\u3002\u5bd2\u6696\u306e\u5dee\u304c\u6fc0\u3057\u3044\u3068\u3001\u81ea\u5f8b\u795e\u7d4c\u306a\u3069\u3082\u4e71\u308c\u304c\u3061\u306b\u306a\u308a\u3001\u4f53\u8abf\u3092\u5d29\u3057\u3084\u3059\u3044\u305d\u3046\u3067\u3059\u3002<br \/>\u5e74\u672b\u3082\u8fd1\u3065\u3044\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u4f53\u8abf\u306e\u7ba1\u7406\u306b\u306f\u5341\u5206\u6ce8\u610f\u3057\u3066\u3001\u3088\u3044\u5e74\u3092\u8fce\u3048\u305f\u3044\u3082\u306e\u3067\u3059\u306d\u3002<br \/>\u307e\u305f\u3001\u30d6\u30ed\u30b0\u3092\u898b\u3066\u9802\u3044\u305f\u7686\u3055\u3093\u3001\u3053\u306e1\u5e74\u3001\u3069\u3046\u3082\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002\u6765\u5e74\u3082\u9811\u5f35\u308a\u307e\u3059\u306e\u3067\u3001\u3088\u308d\u3057\u304f\u304a\u9858\u3044\u3044\u305f\u3057\u307e\u3059\uff01<\/p>\n<p><strong>\uff1c\u672c\u65e5\u306e\u984c\u6750\uff1e<br \/><\/strong>DATEFROMPARTS, DATETIME2FROMPARTS\u95a2\u6570<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/?p=1047\">\u524d\u56de<\/a>\u3001\u65e5\u4ed8\u306e\u66dc\u65e5\u3092\u53d6\u5f97\u3059\u308b\u95a2\u6570\u3068\u3057\u3066\u3001SQL Server\u306eDATEPART\u95a2\u6570\u3001DATENAME\u95a2\u6570\u3068\u3044\u3046\u3082\u306e\u3092\u53d6\u308a\u4e0a\u3052\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u3082\u65e5\u4ed8\u306b\u95a2\u9023\u3059\u308b\u5185\u5bb9\u3067\u3059\u3002<\/p>\n<p>\u3044\u308d\u3044\u308d\u306a\u30b7\u30b9\u30c6\u30e0\u306b\u304a\u3044\u3066\u3001\u5e74\u3084\u6708\u3092\u6307\u5b9a\u3057\u3066\u305d\u306e\u671f\u9593\u5185\u306e\u30c7\u30fc\u30bf\u306b\u3064\u3044\u3066\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u305d\u306e\u3068\u304d\u3001\u6570\u5024\u306a\u3069\u3067\u6307\u5b9a\u3057\u305f\u5e74\u3001\u6708\u304b\u3089\u65e5\u4ed8\u578b\u306b\u5909\u63db\u3059\u308b\u306e\u306bCAST\u95a2\u6570\u306a\u3069\u3092\u4f7f\u7528\u3057\u3066\u6587\u5b57\u306b\u5909\u63db\u3057\u3066\u305d\u308c\u305e\u308c\u3092\u3064\u306a\u3052\u3001\u6700\u5f8c\u306bCONVERT\u95a2\u6570\u306a\u3069\u3067\u65e5\u4ed8\u306b\u5909\u63db\u3057\u3066\u5bfe\u5fdc\u3059\u308b\u3088\u3046\u306a\u3053\u3068\u3092\u884c\u3046\u5fc5\u8981\u304c\u51fa\u3066\u304f\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u5c11\u3057\u4fbf\u5229\u306a\u95a2\u6570\u3092\u898b\u3064\u3051\u307e\u3057\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u3053\u308c\u3092\u53d6\u308a\u4e0a\u3052\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff08SQL Server\u306e\u5834\u5408\uff09<\/p>\n<p>\u305d\u306e\u95a2\u6570\u306f\u3001DATEFROMPARTS\u95a2\u6570\u3001DATETIMEFROMPARTS\u95a2\u6570\u3001DATETIME2FROMPARTS\u95a2\u6570\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002SQL Server2012\u304b\u3089\u6709\u52b9\u306a\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001DATEFROMPARTS\u95a2\u6570\u306b\u3064\u3044\u3066\u3067\u3059\u304c\u3001\u69cb\u6587\u306f\u3001<br \/>DATEFROMPARTS (year, month, day)<br \/>\u5f15\u6570\u306e year, month, day \u306e\u3068\u3053\u308d\u306b\u3001\u305d\u308c\u305e\u308c\u5e74\u3001\u6708\u3001\u65e5\u3092\u793a\u3059\u6574\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u65e5\u4ed8\u306b\u5909\u63db\u3057\u3066\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff09<br \/>\u5e74\u3001\u6708\u3001\u65e5\u3092\u305d\u308c\u305e\u308c\u5909\u6570\u3092\u6301\u305f\u305b\u3066\u5024\u3092\u8a2d\u5b9a\u3057\u3001\u305d\u308c\u3089\u306e\u5024\u306b\u8a72\u5f53\u3059\u308b\u65e5\u4ed8\u3092\u65e5\u4ed8\u578b\u3067\u62bd\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>DECLARE<br \/>\u00a0 @\u5e74 INT = 2015<br \/>, @\u6708 INT = 12<br \/>, @\u65e5 INT = 21<\/p>\n<p>SELECT DATEFROMPARTS (@\u5e74, @\u6708, @\u65e5);<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1088\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts-300x150.png\" alt=\"datefromparts\" width=\"300\" height=\"150\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts-300x150.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts.png 436w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u7c21\u5358\u306b\u65e5\u4ed8\u578b\u306e\u30c7\u30fc\u30bf\u306b\u5909\u63db\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\u3053\u308c\u306f\u3001EXCEL\u306eDATE\u95a2\u6570\u3068\u540c\u3058\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u306d\u3002<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/excel_date.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1089\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/excel_date-300x150.png\" alt=\"excel_date\" width=\"300\" height=\"150\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/excel_date-300x150.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/excel_date.png 355w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u203bSQL Server 2008\u3067\u4e0a\u8a18\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts_2008err.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1118\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts_2008err-300x133.png\" alt=\"datefromparts_2008err\" width=\"300\" height=\"133\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts_2008err-300x133.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datefromparts_2008err.png 515w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u00a0\u203b\u307e\u305f\u3001\u6708\u306e\u5f15\u6570\u90e8\u5206\u309213\u306b\u3059\u308b\u3068\u304b\u3001\u65e5\u306e\u5f15\u6570\u90e8\u5206\u309232\u306a\u3069\u65e5\u4ed8\u3068\u3057\u3066\u5b58\u5728\u3057\u306a\u3044\u5024\u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u3082\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u3092\u3001SQL Server2012\u3088\u308a\u4ee5\u524d\u306e\u5834\u5408\u306a\u3069\u3001\u3053\u306e\u95a2\u6570\u3092\u4f7f\u7528\u3057\u306a\u3044\u3067\u5225\u306e\u3084\u308a\u65b9\u3067\u3084\u308d\u3046\u3068\u3059\u308b\u3068\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>DECLARE<br \/>\u00a0@\u5e74 INT = 2015<br \/>, @\u6708 INT = 12<br \/>, @\u65e5 INT = 21<br \/>, @\u5e74\u6708\u65e5 VARCHAR(8)\u00a0<\/p>\n<p>SET @\u5e74\u6708\u65e5 = CAST(@\u5e74 AS VARCHAR)+CAST(@\u6708 AS VARCHAR)+CAST(@\u65e5 AS VARCHAR)<\/p>\n<p>SELECT CONVERT(date, @\u5e74\u6708\u65e5)<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1092\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date1-300x124.png\" alt=\"convert_date1\" width=\"346\" height=\"143\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date1-300x124.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date1.png 642w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<p>\u00a0\u305f\u3060\u3001\u6708\u3084\u65e5\u304c1\u6841\u306e\u5834\u5408\u3084\u3001\u5e74\u304c4\u6841\u306b\u6e80\u305f\u306a\u3044\u3088\u3046\u306a\u5834\u5408\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u3082\u3046\u4e00\u5de5\u592b\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>DECLARE<br \/>\u00a0 @\u5e74 INT = 2015<br \/>, @\u6708 INT = 9<br \/>, @\u65e5 INT = 1<br \/>, @\u5e74\u6708\u65e5 VARCHAR(8)\u00a0<\/p>\n<p>SET @\u5e74\u6708\u65e5 = CAST(@\u5e74 AS VARCHAR)+CAST(@\u6708 AS VARCHAR)+CAST(@\u65e5 AS VARCHAR)<\/p>\n<p>SELECT CONVERT(date, @\u5e74\u6708\u65e5)<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date2_err1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1094\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date2_err1-300x129.png\" alt=\"convert_date2_err\" width=\"312\" height=\"134\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date2_err1-300x129.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date2_err1.png 605w\" sizes=\"auto, (max-width: 312px) 100vw, 312px\" \/><\/a><\/p>\n<p>\u3053\u308c\u306f\u3001\u4e0a\u8a18\u306e @\u5e74\u6708\u65e5 \u304c\u300c201591\u300d\u3068\u306a\u3063\u3066\u65e5\u4ed8\u306b\u5909\u63db\u3057\u3088\u3046\u3068\u3057\u3066\u3082\u3067\u304d\u306a\u3044\u305f\u3081\u3067\u3059\u3002<br \/>\u3067\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u5de6\u5074\u306b\u300c0\u300d\u3092\u8a70\u3081\u308b\u304b\u305f\u3061\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>SET @\u5e74\u6708\u65e5 = RIGHT(&#8216;0000&#8217;+CAST(@\u5e74 AS VARCHAR), 4) + RIGHT(&#8217;00&#8217;+CAST(@\u6708 AS VARCHAR), 2) + RIGHT(&#8217;00&#8217;+CAST(@\u65e5 AS VARCHAR), 2)<\/p>\n<p>\u5b9f\u969b\u306b\u3084\u3063\u3066\u307f\u308b\u3068\u3001<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date3PNG.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1096\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date3PNG-300x86.png\" alt=\"convert_date3PNG\" width=\"405\" height=\"116\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date3PNG-300x86.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/convert_date3PNG.png 948w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/a><\/p>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u3001@\u5e74\u6708\u65e5\u306f\u300c20150901\u300d\u3068\u306a\u308b\u306e\u3067\u3001\u305d\u306e\u5f8c\u306eCONVERT\u95a2\u6570\u3067\u30a8\u30e9\u30fc\u306b\u306a\u3089\u305a\u306b\u3001\u65e5\u4ed8\u306b\u5909\u63db\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u6b21\u306b\u3001\u6642\u523b\u306b\u3064\u3044\u3066\u3082\u6642\u9593\u3084\u5206\u3001\u79d2\u3092\u540c\u69d8\u306b\u5f15\u6570\u3067\u6e21\u3057\u3066 datetime2\u578b\u306a\u3069\u3067\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u306b\u306f\u3001DATETIME2FROMPARTS\u95a2\u6570\u3068\u3044\u3046\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002<br \/>\uff08datetime\u578b\u306b\u3059\u308b\u5834\u5408\u306f DATETIMEFROMPARTS\u95a2\u6570\u3002datetime\u578b\u3068datetime2\u578b\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/www.dbsheetclient.jp\/blog\/?p=69\">\u4ee5\u524d\u306e\u6295\u7a3f\uff08Oracle\u30fbSQL Server \u65e5\u4ed8\u578b\u306b\u3064\u3044\u3066)<\/a>\u3067\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\uff09<\/p>\n<p>\u4e0b\u8a18\u306b\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>DECLARE<br \/>\u00a0 @\u5e74 INT = 2015<br \/>, @\u6708 INT = 12<br \/>, @\u65e5 INT = 21<br \/>, @\u6642 INT = 16<br \/>, @\u5206 INT = 42<br \/>, @\u79d2 INT = 34<br \/>, @\u79d2_\u5c0f\u6570 INT = 525<\/p>\n<p>SELECT DATETIME2FROMPARTS (@\u5e74, @\u6708, @\u65e5, @\u6642, @\u5206, @\u79d2, @\u79d2_\u5c0f\u6570, 3);<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datetime2fromparts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1099\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datetime2fromparts-300x127.png\" alt=\"datetime2fromparts\" width=\"333\" height=\"141\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datetime2fromparts-300x127.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/datetime2fromparts.png 613w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/a><\/p>\n<p>\u6307\u5b9a\u3057\u305f\u5024\u3092\u5143\u306b\u3001datetime2\u578b\u3067\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<br \/>\u69cb\u6587\u306f\u3001<\/p>\n<p>DATETIME2FROMPARTS (year, month, day, hour, minute, seconds, fractions, precision)<\/p>\n<p>\u5f15\u6570\u306b\u3064\u3044\u3066\u306f\u4e0b\u8a18\uff1a<br \/>year\u00a0\u00a0\u00a0\u00a0 \uff1a\u5e74\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>month\u00a0\u00a0\u00a0 \uff1a\u6708\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>day\u00a0\u00a0\u00a0\u00a0\u00a0 \uff1a\u65e5\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>hour\u00a0\u00a0\u00a0\u00a0 \uff1a\u6642\u9593\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>minute\u00a0\u00a0 \uff1a\u5206\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>seconds\u00a0 \uff1a\u79d2\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>fractions\uff1a\u5c0f\u6570\u90e8\u5206\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u5f0f\u3002<br \/>precision\uff1a\u8fd4\u3055\u308c\u308b datetime2 \u5024\u306e\u6709\u52b9\u6841\u6570\u3092\u6307\u5b9a\u3059\u308b\u6574\u6570\u30ea\u30c6\u30e9\u30eb\u3002<\/p>\n<p>\u3055\u3066\u3001<strong>ORACLE<\/strong>\u3067\u540c\u69d8\u306e\u3053\u3068\u3092\u3059\u308b\u5834\u5408\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3001\u305d\u308c\u305e\u308c\u306e\u6570\u5024\u3092\u4e00\u65e6TO_CHAR\u95a2\u6570\u3067\u6587\u5b57\u3067\u3064\u306a\u3052\u305f\u5f8c\u306b\u3001\u65e5\u4ed8\u578b\uff08\u4eca\u56de\u306f\u30df\u30ea\u79d2\u304c\u3042\u308b\u306e\u3067TIMESTAMP\u578b\uff09\u306bTO_TIMESTAMP\u95a2\u6570\u3067\u5909\u63db\u3059\u308b\u306a\u3069\u306e\u51e6\u7406\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u203b\u4eca\u56de\u306f\u3001TIMESTAMP\u578b\u306b\u5909\u63db\u3057\u305f\u5f8c\u3001SQL Server\u306e\u3068\u304d\u3068\u540c\u69d8\u306e\u5f62\u5f0f\u3067\u7d50\u679c\u3092\u8868\u793a\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u6700\u5f8c\u306bTO_CHAR\u95a2\u6570\u3067\u66f8\u5f0f\u3092\u6574\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>DECLARE<br \/>\u00a0 V_\u5e74 INT := 2015;<br \/>\u00a0 V_\u6708 INT := 9;<br \/>\u00a0 V_\u65e5 INT := 1;<br \/>\u00a0 V_\u6642 INT := 16;<br \/>\u00a0 V_\u5206 INT := 42;<br \/>\u00a0 V_\u79d2 INT := 34;<br \/>\u00a0 V_\u79d2_\u5c0f\u6570 INT := 525;<br \/>\u00a0 V_\u65e5\u4ed8\u6587\u5b57 VARCHAR2(30);<br \/>\u00a0 V_\u65e5\u4ed8 TIMESTAMP;<br \/>\u00a0 V_\u65e5\u4ed8\u5909\u63db VARCHAR2(30);<\/p>\n<p>BEGIN<br \/>\u00a0 V_\u65e5\u4ed8\u6587\u5b57 := TRIM(TO_CHAR(V_\u5e74,&#8217;0999&#8242;))||TRIM(TO_CHAR(V_\u6708,&#8217;09&#8217;))||TRIM(TO_CHAR(V_\u65e5,&#8217;09&#8217;))||TRIM(TO_CHAR(V_\u6642,&#8217;09&#8217;))||TRIM(TO_CHAR(V_\u5206,&#8217;09&#8217;))||TRIM(TO_CHAR(V_\u79d2,&#8217;09&#8217;))||TRIM(TO_CHAR(V_\u79d2_\u5c0f\u6570,&#8217;099&#8242;));<\/p>\n<p>\u00a0 DBMS_OUTPUT.PUT_LINE(V_\u65e5\u4ed8\u6587\u5b57);\u00a0<\/p>\n<p>\u00a0 SELECT TO_TIMESTAMP(V_\u65e5\u4ed8\u6587\u5b57, &#8216;YYYY-MM-DD HH24:MI:SS FF3&#8217;) INTO V_\u65e5\u4ed8 FROM DUAL;<\/p>\n<p>\u00a0 DBMS_OUTPUT.PUT_LINE(V_\u65e5\u4ed8);<\/p>\n<p>\u00a0 SELECT TO_CHAR(V_\u65e5\u4ed8, &#8216;YYYY-MM-DD HH24:MI:SS.FF3&#8217;) INTO V_\u65e5\u4ed8\u5909\u63db FROM DUAL;<\/p>\n<p>\u00a0 DBMS_OUTPUT.PUT_LINE(V_\u65e5\u4ed8\u5909\u63db);<br \/>END;<br \/>\/<\/p>\n<p><a href=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/oracle_timestamp2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-1104\" src=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/oracle_timestamp2-300x171.png\" alt=\"oracle_timestamp2\" width=\"453\" height=\"258\" srcset=\"https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/oracle_timestamp2-300x171.png 300w, https:\/\/www.dbsheetclient.jp\/blog\/wp-content\/uploads\/2015\/12\/oracle_timestamp2.png 976w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/a><\/p>\n<p>\u6570\u5024\u3067\u8a2d\u5b9a\u3057\u305f\u5e74\u3001\u6708\u3001\u65e5\u3001\u6642\u9593\u3001\u5206\u3001\u79d2\u3001\u30df\u30ea\u79d2\u306e\u5024\u3092\u5143\u306b\u3001V_\u65e5\u4ed8\u3068\u3044\u3046 TIMESTAMP\u578b\u306e\u5909\u6570\u306b\u5909\u63db\u3055\u308c\u305f\u5024\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b\u6708\u30671\u6841\u306e\u3082\u306e\u30922\u6841\u306e\u6587\u5b57\u3067\u8868\u793a\u3059\u308b\u5834\u5408\u306a\u3069\u306b\u3001\u66f8\u5f0f\u3068\u3057\u3066TO_CHAR(\u9805\u76ee, \u201809\u2019)\u3068\u3044\u3046\u3088\u3046\u306b\u3059\u308b\u3068\u30012\u6841\u306b\u8db3\u3089\u306a\u3044\u5834\u5408\u306b\u306f\u3001\u982d\u306b\u300c0\u300d\u3092\u57cb\u3081\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30df\u30ea\u79d2\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u304d\u306e\u66f8\u5f0f\u306f\u3001\u300cFF[1-9]\u300d\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u3001\u4eca\u56de\u306e\u5c0f\u6570\u70b9\u4ee5\u4e0b3\u6841\u306e\u5834\u5408\u306f\u3001\u300cFF3\u300d\u3068\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u4ee5\u4e0a\u307e\u3067<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IT\u30b3\u30fc\u30c7\u30a3\u30cd\u30fc\u30bf\u306e\u30b7\u30e5\u30a6\u3067\u3059\u3002 \u4eca\u5e74\u306f\u6696\u51ac\u3068\u8a00\u308f\u308c\u3066\u304a\u308a\u3001\u30b9\u30ad\u30fc\u5834\u3067\u306f\u96ea\u4e0d\u8db3\u306e\u3068\u3053\u308d\u3082\u7d50\u69cb\u3042\u3063\u3066\u5fc3\u914d\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u6025\u306b\u5bd2\u304f\u306a\u3063\u305f\u308a\u3082\u3057\u307e\u3059\u306d\u3002\u6696\u51ac\u3068\u3044\u3046\u306e\u306f\u3001\u6696\u304b\u3044\u65e5\u304c\u7d9a\u304f\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u306a\u304f\u3001\u5e73\u5747\u3057\u3066\u6696\u304b\u3044\u3068\u3044\u3046\u3053\u3068 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[],"class_list":["post-1082","post","type-post","status-publish","format-standard","hentry","category-5"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1082"}],"version-history":[{"count":26,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1082\/revisions"}],"predecessor-version":[{"id":1938,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1082\/revisions\/1938"}],"wp:attachment":[{"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbsheetclient.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}