{"id":1444,"date":"2015-04-21T10:32:22","date_gmt":"2015-04-21T01:32:22","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1444"},"modified":"2015-08-26T01:58:34","modified_gmt":"2015-08-25T16:58:34","slug":"datediff","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/datediff\/","title":{"rendered":"\u65e5\u4ed8\u6642\u523b\uff1a\u65e5\u4ed8\u30fb\u6642\u523b\u306e\u9593\u9694\u3092\u53d6\u5f97\uff08 DateDiff \u95a2\u6570 \uff09"},"content":{"rendered":"<h2>DateDiff \u95a2\u6570\u306e\u4f7f\u3044\u65b9<\/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>DateDiff<\/strong> ( <em>interval<\/em>, <em>date1<\/em>, <em>date2<\/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;\u53d6\u5f97\u3059\u308b\u65e5\u4ed8\u9593\u306e\u9593\u9694\u306e\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=\"#datediff_interval\">\u6642\u523b\u30fb\u6642\u9593\u5358\u4f4d\u306e\u8a2d\u5b9a\u5024\u8868<\/a>\u300d\u3092\u53c2\u7167 \uff09\u3002<\/li>\n<li>date1,date2&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u6bd4\u8f03\u3059\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=\"#datediff_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=\"#datediff_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;\uff12\u3064\u306e\u65e5\u4ed8\u30fb\u6642\u9593\uff08 <em>date1<\/em> \u3068 <em>date2<\/em> \uff09\u306e\u9593\u9694\u3092\u8868\u3059\u6570\u5024\uff08Long \u578b\uff09\u3002<\/li>\n<\/ul>\n<br \/><br \/>\n<p id=\"datediff_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\"><strong>d<\/strong> \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3068\u540c\u3058<\/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\">w<\/td>\n<td align = \"center\" width=\"150\">\u9031\u65e5<\/td>\n<td width=\"150\">\u9031\u9593\u6570\uff08 <em>date1<\/em> \u306e\u66dc\u65e5\u304b\u3089 <em>date2<\/em> \u307e\u3067\u306e\u305d\u306e\u66dc\u65e5\u306e\u6570\u3002\u305f\u3060\u3057 <em>date1<\/em> \u81ea\u4f53\u306f\u6570\u306b\u542b\u3081\u306a\u3044\uff09\u3002<\/td>\n<\/tr>\n<tr>\n<td align = \"center\" width=\"100\">ww<\/td>\n<td align = \"center\" width=\"150\">\u9031<\/td>\n<td width=\"150\">\u9031\u9593\u6570\uff08 <em>date1<\/em> \u304b\u3089 <em>date2<\/em> \u307e\u3067\u306e\u65e5\u66dc\u65e5\u306e\u6570\u3002\u305f\u3060\u3057 <em>date1<\/em> \u304c\u65e5\u66dc\u65e5\u306e\u5834\u5408\u3001<em>date1<\/em> \u306f\u6570\u306b\u542b\u3081\u306a\u3044\uff09\u3002<\/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=\"datediff_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=\"datediff_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>DateDiff \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=\"DateDiff \u95a2\u6570\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_DateDiff()\r\n\r\n    Dim myDate1 As Date, myDate2 As Date\r\n    Dim msg\r\n    \r\n    myDate1 = #4\/20\/2005 7:08:21 PM#\r\n    myDate2 = Now\r\n    \r\n    msg = \"myDate1\u3000\u3000\uff1a\" & myDate1 & Chr(13) & _\r\n          \"myDate2\u3000\u3000\uff1a\" & myDate2 & Chr(13) & _\r\n          \"yyyy\uff08\u5e74\uff09 \uff1a\" & DateDiff(\"yyyy\", myDate1, myDate2) & Chr(13) & _\r\n          \"m\uff08\u6708\uff09\u3000\u3000\uff1a\" & DateDiff(\"m\", myDate1, myDate2) & Chr(13) & _\r\n          \"d\uff08\u65e5\uff09\u3000\u3000\uff1a\" & DateDiff(\"d\", myDate1, myDate2) & Chr(13) & _\r\n          \"ww\uff08\u9031\uff09\u3000 \uff1a\" & DateDiff(\"ww\", myDate1, myDate2) & Chr(13) & _\r\n          \"y\uff08\u5e74\u65e5\uff09\u3000\uff1a\" & DateDiff(\"y\", myDate1, myDate2) & Chr(13) & _\r\n          \"w\uff08\u9031\u65e5\uff09\u3000\uff1a\" & DateDiff(\"w\", myDate1, myDate2) & Chr(13) & _\r\n          \"q\uff08\u56db\u534a\u671f\uff09\uff1a\" & DateDiff(\"q\", myDate1, myDate2) & Chr(13) & _\r\n          \"h\uff08\u6642\uff09\u3000\u3000\uff1a\" & DateDiff(\"h\", myDate1, myDate2) & Chr(13) & _\r\n          \"n\uff08\u5206\uff09\u3000\u3000\uff1a\" & DateDiff(\"n\", myDate1, myDate2) & Chr(13) & _\r\n          \"s\uff08\u79d2\uff09\u3000\u3000\uff1a\" & DateDiff(\"s\", myDate1, myDate2)\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:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01.jpg?ssl=1\" rel=\"lightbox[1444]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01.jpg?resize=359%2C400&#038;ssl=1\" alt=\"DateDiff \u95a2\u6570\u3000\u4f7f\u7528\u4f8b\" width=\"359\" height=\"400\" class=\"alignnone size-medium wp-image-1447\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01.jpg?resize=359%2C400&amp;ssl=1 359w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01.jpg?resize=580%2C646&amp;ssl=1 580w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01.jpg?w=593&amp;ssl=1 593w\" sizes=\"(max-width: 359px) 100vw, 359px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>DateDiff \u95a2\u6570\u306e\u4f7f\u3044\u65b9 \u3010\u66f8\u5f0f\u3011 result = DateDiff ( &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1449,"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\u30fb\u6642\u523b\u306e\u9593\u9694\u3092\u53d6\u5f97\uff08 DateDiff \u95a2\u6570 \uff09"},"categories":[37],"tags":[143,63,38,144],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/datediff01-359x4001.jpg?fit=359%2C400&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s4Ye9i-datediff","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1444"}],"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=1444"}],"version-history":[{"count":4,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1444\/revisions"}],"predecessor-version":[{"id":3370,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1444\/revisions\/3370"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1449"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}