wondering how i can get the number of days of a specific month..
like if i entered january of 2015... it shows 31 days
december of 2014.. has 31 days
Moderator: Neosoft Support
yanzco wrote:january of 2015
DateToNum "1.01.15" "d/m/y" "[Result]"
DateToNum "1.02.15" "d/m/y" "[Result2]"
SetVar "[Result]" "[Result2]-[Result]"
yanzco wrote:december of 2014
DateToNum "1.12.14" "d/m/y" "[Result]"
DateToNum "1.01.15" "d/m/y" "[Result2]"
SetVar "[Result]" "[Result2]-[Result]"
DateToNum "1.02.14" "d/m/y" "[Result]"
DateToNum "1.03.14" "d/m/y" "[Result2]"
SetVar "[Result]" "[Result2]-[Result]"
.1. Обозначим число, месяц и год соответственно d, m и y.
.2. Если m <= 2 (т.е. месяц январь или февраль), то год уменьшим на 1, а число увеличим на 3:
. y:= y–1;
. d:= d+3;
.3. Теперь номер дня недели (w) вычисляется по следующей формуле:
. w:= 1 + [d + y + y/4 – y/100 + y/400 + (31m+10)/12] mod 7;
.(все операции деления — целочисленные, т.е. берется целая часть частного; mod — операция получения остатка от деления).
.Результатом будет целое число в диапазоне от 1 до 7, соответствующее дням недели от воскресенья до субботы
.(1 — понедельник, 2 — вторник, 3 — среда, 4 — четверг, 5 — пятница, 6 — суббота, 7 — воскресенье).
If "[m]" "<=" "2"
SetVar "[y]" "[y]-1"
SetVar "[d]" "[d]+3"
EndIf
Math "[d]+[y]+Trunc([y]/4)-Trunc([y]/100)+Trunc([y]/400)+Trunc((31*[m]+10)/12)" "0" "[Result]"
Math "[Result]-Trunc([Result]/7)*7+1" "0" "[Result]"
yanzco wrote:wondering how i can get the number of days of a specific month..
like if i entered january of 2015... it shows 31 days
december of 2014.. has 31 days
dpayer wrote:If you'd like to see some other tools regarding dates, take a look at a function I made for a popup calendar.
http://neosoftware.com/community/viewto ... 22&t=20140
SetVar "[thisYear]" "2015"
SetVar "[thisMonth]" "1"
GoSub "mishemDaysInMonth"
Call "mishemDaysInMonth" "[thisYear]" "[thisMonth]" "[thisVarForAnswer]"
mishem wrote:We are not looking for easy ways ...
Call "LastDayOfMonth" "[Input_Date]" "[Output_Number]"
setvar "[dd]" "31"
.. In TextEntry
... [yy] 14
... [mm] 2
:Day
DateToNum "[dd]/[mm]/[yy]" "d/m/y" "[dmy]"
if "[Dmy]" "=" "Error"
math "[dd]-1" "" "[dd]"
gotoline "Day"
endif
Alertbox "" "Month [Mm] With [DD] Days"
Return to General NeoBook Discussions
Users browsing this forum: No registered users and 4 guests