{"id":1435,"date":"2015-04-20T23:39:01","date_gmt":"2015-04-20T14:39:01","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1435"},"modified":"2015-08-26T02:01:13","modified_gmt":"2015-08-25T17:01:13","slug":"datepart","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/datepart\/","title":{"rendered":"\u65e5\u4ed8\u6642\u523b\uff1a\u65e5\u4ed8\u6642\u523b\u304b\u3089\u60c5\u5831\u53d6\u5f97\uff08 DatePart \u95a2\u6570 \uff09"},"content":{"rendered":"<h2>DatePart \u95a2\u6570\uff08\u65e5\u4ed8\u30fb\u6642\u523b\u306e\u5024\u304b\u3089\u60c5\u5831\u3092\u53d6\u5f97\uff09<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p><em>result<\/em> = <strong>DatePart<\/strong> ( <em>interval<\/em>, <em>date<\/em>, [ <em>firstdayofweek<\/em>, <em>firstweekofyear<\/em> ] )<\/p>\n<\/div>\n<br \/>\n<h3>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h3>\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>interval&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u8abf\u3079\u305f\u3044\u60c5\u5831\u306b\u5bfe\u5fdc\u3059\u308b\u300c<strong>\u6642\u523b\u30fb\u6642\u9593\u306e\u5358\u4f4d<\/strong>\u300d\u3092\u8868\u3059\u6587\u5b57\u5217\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u300c<a href=\"#datepart_interval\">\u6642\u523b\u30fb\u6642\u9593\u5358\u4f4d\u306e\u8a2d\u5b9a\u5024\u8868<\/a>\u300d\u3092\u53c2\u7167 \uff09\u3002<\/li>\n<li>date&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u57fa\u6e96\u3068\u306a\u308b<strong>\u65e5\u4ed8\u30fb\u6642\u523b<\/strong>\u3092\u6307\u5b9a\u3057\u307e\u3059\uff08\u5185\u90e8\u51e6\u7406\u5f62\u5f0f Date \u306e\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\u306e\u5024\u3001\u3082\u3057\u304f\u306f\u30ea\u30c6\u30e9\u30eb\u6587\u5b57\u5217\uff09\u3002<\/li>\n<li>firstdayofweek&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>\u9031\u306e\u59cb\u307e\u308a\u306e\u66dc\u65e5\u3092\u8868\u3059\u5b9a\u6570<\/strong>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7701\u7565\u3059\u308b\u3068\u65e5\u66dc\u65e5\u3092\u6307\u5b9a\u3057\u305f\u3082\u306e\u3068\u307f\u306a\u3055\u308c\u307e\u3059\uff08\u300c<a href=\"#datepart_firstdayofweek\">\u9031\u306e\u59cb\u307e\u308a\u306e\u66dc\u65e5\u3092\u793a\u3059\u5b9a\u6570<\/a>\u300d\u3092\u53c2\u7167 \uff09\u3002<\/li>\n<li>firstweekofyear&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>\u5e74\u5ea6\u306e\u7b2c 1 \u9031\u3092\u8868\u3059\u5b9a\u6570<\/strong>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7701\u7565\u3059\u308b\u3068\u30011 \u6708 1 \u65e5\u3092\u542b\u3080\u9031\u304c\u7b2c 1 \u9031\u3068\u307f\u306a\u3055\u308c\u307e\u3059\uff08\u300c<a href=\"#datepart_firstweekofyear\">\u5e74\u5ea6\u306e\u59cb\u307e\u308a\u3092\u793a\u3059\u5b9a\u6570<\/a>\u300d\u3092\u53c2\u7167 \uff09\u3002<\/li>\n<li>result&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>date<\/em> \u306b\u5bfe\u3057\u3066\u3001<em>interval<\/em> \u3067\u6307\u5b9a\u3057\u305f\u5358\u4f4d\u306b\u5bfe\u5fdc\u3059\u308b\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\uff08\u5185\u90e8\u51e6\u7406\u5f62\u5f0f Integer\uff09\u306e\u5024\u3002<\/li>\n<\/ul>\n<br \/><br \/>\n<p id=\"datepart_interval\" class=\"caution4\"><strong>\u6642\u523b\u30fb\u6642\u9593\u5358\u4f4d\u306e\u8a2d\u5b9a\u5024\u8868\uff08<em>interval<\/em> \u306b\u6307\u5b9a\u3059\u308b\u5024\uff09<\/strong><\/p>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"100\" bgcolor=\"#ffffcc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"150\" bgcolor=\"#ffffcc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<td align = \"center\" width=\"300\" bgcolor=\"#ffffcc\"><strong>\u5099\u8003<\/strong><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">yyyy<\/td>\n<td align = \"center\" width=\"150\">\u5e74<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">q<\/td>\n<td align = \"center\" width=\"150\">\u56db\u534a\u671f<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">m<\/td>\n<td align = \"center\" width=\"150\">\u6708<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">y<\/td>\n<td align = \"center\" width=\"150\">\u5e74\u9593\u901a\u7b97\u65e5<\/td>\n<td width=\"150\">\u5143\u65e6\u304b\u3089\u6570\u3048\u3066\u4f55\u65e5\u304b<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">d<\/td>\n<td align = \"center\" width=\"150\">\u65e5<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">ww<\/td>\n<td align = \"center\" width=\"150\">\u9031\u65e5<\/td>\n<td width=\"150\">\u5e74\u306e\u59cb\u307e\u308a\u306e\u9031\u304b\u3089\u6570\u3048\u3066\u4f55\u9031\u76ee\u304b<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">w<\/td>\n<td align = \"center\" width=\"150\">\u9031<\/td>\n<td width=\"150\">\u9031\u521d\u3081\u304b\u3089\u6570\u3048\u3066\u4f55\u756a\u76ee\u304b<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">h<\/td>\n<td align = \"center\" width=\"150\">\u6642<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">n<\/td>\n<td align = \"center\" width=\"150\">\u5206<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">s<\/td>\n<td align = \"center\" width=\"150\">\u79d2<\/td>\n<td width=\"150\"><\/td>\n<\/tr>\n<\/table>\n<\/div>\n<br \/><br \/>\n<p id=\"datepart_firstdayofweek\" class=\"caution4\"><strong>\u9031\u306e\u59cb\u307e\u308a\u306e\u66dc\u65e5\u3092\u793a\u3059\u5b9a\u6570\uff08<em>firstdayofweek<\/em> \u306b\u6307\u5b9a\u3059\u308b\u5024\uff09<\/strong><\/p>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"100\" bgcolor=\"#ffffcc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"150\" bgcolor=\"#ffffcc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"300\" bgcolor=\"#ffffcc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td align = \"center\">0<\/td>\n<td>vbUseSystem<\/td>\n<td>NLS\uff08\u30b7\u30b9\u30c6\u30e0\u306e\u5404\u56fd\u5bfe\u5fdc\uff09API\u306e\u8a2d\u5b9a\u5024\u3092\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">1<\/td>\n<td>vbSunday<\/td>\n<td>\u65e5\u66dc\u65e5\uff08\u898f\u5b9a\u5024\uff09<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">2<\/td>\n<td>vbMonday<\/td>\n<td>\u6708\u66dc\u65e5<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">3<\/td>\n<td>vbTuesday<\/td>\n<td>\u706b\u66dc\u65e5<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">4<\/td>\n<td>vbWednesday<\/td>\n<td>\u6c34\u66dc\u65e5<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">5<\/td>\n<td>vbThursday<\/td>\n<td>\u6728\u66dc\u65e5<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">6<\/td>\n<td>vbFriday<\/td>\n<td>\u91d1\u66dc\u65e5<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">7<\/td>\n<td>vbSaturday<\/td>\n<td>\u571f\u66dc\u65e5<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<br \/><br \/>\n<p id=\"datepart_firstweekofyear\" class=\"caution4\"><strong>\u5e74\u5ea6\u306e\u59cb\u307e\u308a\u3092\u793a\u3059\u5b9a\u6570\uff08<em>firstweekofyear<\/em> \u306b\u6307\u5b9a\u3059\u308b\u5024\uff09<\/strong><\/p>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"100\" bgcolor=\"#ffffcc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"150\" bgcolor=\"#ffffcc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"300\" bgcolor=\"#ffffcc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">0<\/td>\n<td width=\"150\">vbUseSystem<\/td>\n<td width=\"300\">NLS\uff08\u30b7\u30b9\u30c6\u30e0\u306e\u5404\u56fd\u5bfe\u5fdc\uff09API\u306e\u8a2d\u5b9a\u5024\u3092\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">1<\/td>\n<td width=\"150\">vbFirstJan1<\/td>\n<td width=\"300\">1\u67081\u65e5\u3092\u542b\u3080\u9031\u3092\u5e74\u5ea6\u306e\u7b2c1\u9031\u3068\u3059\u308b\uff08\u898f\u5b9a\u5024\uff09<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">2<\/td>\n<td width=\"150\">vbFirstFourDays<\/td>\n<td width=\"300\">7\u65e5\u306e\u3046\u3061\u5c11\u306a\u304f\u3068\u30824\u65e5\u304c\u65b0\u5e74\u5ea6\u306b\u542b\u307e\u308c\u308b\u9031\u3092\u5e74\u5ea6\u306e\u7b2c1\u9031\u3068\u3059\u308b<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">3<\/td>\n<td width=\"150\">vbFirstFullWeek<\/td>\n<td width=\"300\">\u5168\u4f53\u304c\u65b0\u5e74\u5ea6\u306b\u542b\u307e\u308c\u308b\u6700\u521d\u306e\u9031\u3092\u5e74\u5ea6\u306e\u7b2c1\u9031\u3068\u3059\u308b<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<br \/><br \/><br \/>\n<h2>DatePart \u95a2\u6570\u306e\u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"DatePart \u95a2\u6570\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_DatePart()\r\n\r\n    Dim myDate As Date\r\n    Dim msg\r\n    \r\n    myDate = #4\/20\/2005 7:08:21 PM#\r\n    \r\n    msg = \"\u5143 \u65e5\u4ed8\u3000\u3000\uff1a\" & myDate & Chr(13) & _\r\n          \"yyyy\uff08\u5e74\uff09 \uff1a\" & DatePart(\"yyyy\", myDate, 1, 4) & Chr(13) & _\r\n          \"m\uff08\u6708\uff09\u3000\u3000\uff1a\" & DatePart(\"m\", myDate, 1, 3) & Chr(13) & _\r\n          \"d\uff08\u65e5\uff09\u3000\u3000\uff1a\" & DatePart(\"d\", myDate) & Chr(13) & _\r\n          \"ww\uff08\u9031\uff09\u3000 \uff1a\" & DatePart(\"ww\", myDate) & Chr(13) & _\r\n          \"y\uff08\u5e74\u65e5\uff09\u3000\uff1a\" & DatePart(\"y\", myDate) & Chr(13) & _\r\n          \"w\uff08\u9031\u65e5\uff09\u3000\uff1a\" & DatePart(\"w\", myDate) & Chr(13) & _\r\n          \"q\uff08\u56db\u534a\u671f\uff09\uff1a\" & DatePart(\"q\", myDate) & Chr(13) & _\r\n          \"h\uff08\u6642\uff09\u3000\u3000\uff1a\" & DatePart(\"h\", myDate) & Chr(13) & _\r\n          \"n\uff08\u5206\uff09\u3000\u3000\uff1a\" & DatePart(\"n\", myDate) & Chr(13) & _\r\n          \"s\uff08\u79d2\uff09\u3000\u3000\uff1a\" & DatePart(\"s\", myDate)\r\n    \r\n    Debug.Print msg\r\n\r\n\r\nEnd Sub\r\n\u3000\r\n<\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datepart01.jpg?ssl=1\" rel=\"lightbox[1435]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datepart01.jpg?resize=343%2C400&#038;ssl=1\" alt=\"DatePart \u95a2\u6570 \u4f7f\u7528\u4f8b\" width=\"343\" height=\"400\" class=\"alignnone size-medium wp-image-1441\" srcset=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datepart01.jpg?resize=343%2C400&amp;ssl=1 343w, https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datepart01.jpg?w=561&amp;ssl=1 561w\" sizes=\"(max-width: 343px) 100vw, 343px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>DatePart \u95a2\u6570\uff08\u65e5\u4ed8\u30fb\u6642\u523b\u306e\u5024\u304b\u3089\u60c5\u5831\u3092\u53d6\u5f97\uff09 \u3010\u66f8\u5f0f\u3011 result  &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1443,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":"\u65e5\u4ed8\u6642\u523b\uff1a\u65e5\u4ed8\u6642\u523b\u304b\u3089\u60c5\u5831\u53d6\u5f97\uff08 DatePart \u95a2\u6570 \uff09"},"categories":[37],"tags":[141,63,38,142],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datepart01-343x4001.jpg?fit=343%2C400&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s4Ye9i-datepart","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1435"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=1435"}],"version-history":[{"count":9,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1435\/revisions"}],"predecessor-version":[{"id":3371,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1435\/revisions\/3371"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1443"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}