start and end date of a month
Hello everyone
I use cache script, I would like to know from you if there is any function or class in the cache where I can get the start and end date of a given month:
Example: What is the first and last day of the month of February 2015.
Grateful.
Davidson
Product version: Caché 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.5 (Build 659) Mon Mar 22 2021 07:15:21 EDT
Olá, bom dia
Espero que ajude
ClassMethod ValidaData(strData As %String) As %Boolean
{
New (strData)
;
If strData'?2N1"/"2N1"/"4N Quit 0
Set (Mult,Div,Resto,Dia,Mes,Ano)=""
Set Dia=$P(strData,"/",1)
Set Mes=$P(strData,"/",2)
Set Ano=$P(strData,"/",3)
If (Dia<"01") Quit 0
If (Mes>"12")!(Mes<"01") Quit 0
If (Ano<1900)!(Ano>2050) Quit 0
If (Mes="01")!(Mes="03")!(Mes="05")!(Mes="07")&(Dia>31) Quit 0
If (Mes="08")!(Mes="10")!(Mes="12")&(Dia>31) Quit 0
If (Mes="04")!(Mes="06")!(Mes="09")!(Mes="11")&(Dia>30) Quit 0
If (Mes="02")&(Dia>29) Quit 0
If (Mes="02") {
Set Resto=Ano#4
;Set Div=Ano\4
;Set Mult=Div*4
;Set Resto=Ano-Mult
If (Resto=0)&(Dia>29) Quit 0
If (Resto>0)&(Dia>28) Quit 0
}
Quit 1
}
max day of the month :
max= 28+$e(3_(Ano#4=0)_3232332323,Mes)