Microsoft Dynamics NAV — How To: Find Start Date and End Date of Previous Month

 —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —















Sup­port trans­la­tion: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —
Microsoft Dynam­ics NAV — How To: Find Start Date and End Date of Pre­vi­ous Month

Local/Global Vari­ables:

Name Data­Type Sub­type Length
StartDate Date
End­Date Date

StartDate = Start­ing date of last month.
End­Date = Last day of last month.
StartDate := CALCDATE(‘<-CM-1M>’); //StartDate = 01/08/2012
End­Date := CALCDATE(‘CM’,StartDate); //EndDate = 31/08/2012.
CALCDATE

From Microsoft Dynam­ics NAV 2009 R2 Help.
Cal­cu­lates a new date that is based on a date expres­sion and a ref­er­ence date.
NewD­ate := CALCDATE(DateExpression [, Date])
Para­met­ers
Date­Ex­pres­sion
Type: Text, Code, or Date­For­mu­la
The date expres­sion can be any length. The string is inter­preted from left to right with one subex­pres­sion at a time. The fol­low­ing rules describe the val­id syn­tax of date expres­sions:
· Date­Ex­pres­sion = [<SubExpression>][<SubExpression>][<SubExpression>]
· <SubEx­pres­sion> = [<Sign>] <Term>
· <Sign> = + | -
· <Term> = <Number><Unit> | <Unit><Number> | <Prefix><Unit>
· <Num­ber> = Pos­it­ive integer
· <Unit> = D | WD | W | M | Q | Y (D=day, WD=weekday, W=week, M=month, Q=quarter, Y=year)
· <Pre­fix> = C (C=current)
These pro­duc­tion rules show that date expres­sions con­sist of zero, one, two, or three subex­pres­sions. Each subex­pres­sion com­prises an option­al sign and a term. The fol­low­ing are some typ­ic­al examples of terms:
· 30D (30 days; cor­res­ponds to <Number><Unit>)
· WD2 (week­day num­ber 2; cor­res­ponds to <Unit><Number>)
· CW (cur­rent week; cor­res­ponds to <Prefix><Unit>)
The intern­al cal­en­dar of C/SIDE starts on Monday and ends on Sunday. This means that Monday is week­day 1 and Sunday is week­day 7.
A run-time error occurs if the syn­tax of Date­Ex­pres­sion is incor­rect.
Date
Type: Date
Use this option­al para­met­er to define a ref­er­ence date. The default is the cur­rent sys­tem date.
If you omit this option­al value the cur­rent sys­tem date is used.

Prop­er­ty Value/Return Value
Type: Date
The date that is com­puted from the ref­er­ence date and the date expres­sion.

Remarks
Date­Ex­pres­sion can be a field or vari­able of type Text or Code, and it can be a field or vari­able of type DATEFORMULA. The bene­fit of using a Date­For­mu­la field or vari­able is that the date for­mu­la becomes lan­guage inde­pend­ent.
The user can enter for­mu­las in the cur­rently selec­ted lan­guage. The for­mu­la is stored in a gen­er­ic form­at in a field or vari­able. When the for­mu­la needs to be dis­played, the actu­al string that is dis­played is con­ver­ted to the cur­rently selec­ted lan­guage.
For example, if a user with lan­guage set to ENG (Eng­lish) enters the date for­mu­la ““1W+1D”” for one week and one day, then a user with the lan­guage set to FRA (French) sees ““1S+1J,”” and a user with the lan­guage set to ESP (Span­ish) sees ““1S+1D””.
If a date for­mu­la is entered with < > delim­iters sur­round­ing it, then the date for­mu­la is stored in a gen­er­ic, non­lan­guage-depend­ent form­at. This makes it pos­sible to develop date for­mu­las that are not depend­ent on the cur­rently selec­ted lan­guage.
For more inform­a­tion about cal­cu­lat­ing the dur­a­tion between two Dat­e­Times, see Dur­a­tion Data Type.

Example 1

This code example shows how to use the pro­duc­tion rules that were pre­vi­ously described.
Copy Code
<CQ+1M-10D>
This should be inter­preted as the fol­low­ing: cur­rent quarter + 1 month — 10 days.
The Date­Ex­pres­sion is com­posed of the fol­low­ing:
<Prefix><Unit><Sign><Number><Unit><Sign><Number><Unit>
Note
The angle brack­ets (< >) spe­cify that the expres­sion is not trans­lated, regard­less of the applic­a­tion lan­guage. For more inform­a­tion about mul­til­an­guage cap­ab­il­it­ies with date for­mu­las, see Devel­op­ing Mul­til­an­guage-Enabled Applic­a­tions.

Example 2

This example shows how to use the CALCDATE func­tion.
This code example requires that you cre­ate the fol­low­ing text con­stants in the C/AL Glob­als win­dow.
Text con­stant
ENU value
Tex­t000
The ref­er­ence date is: %1 \’
Tex­t001
The expres­sion: %2 returns %3\’
Tex­t002
The expres­sion: %4 returns %5\’
Tex­t003
The expres­sion: %6 returns %7
Copy Code
Expr1 := ‘<CQ+1M-10D>’; // Cur­rent quarter + 1 month — 10 days
Expr2 := ‘<-WD2>’; // The last week­day no.2, (last Tues­day)
Expr3 := ‘<CM+30D>’; // Cur­rent month + 30 days
Ref­D­ate := 052196D;
Date1 := CALCDATE(Expr1, Ref­D­ate);
Date2 := CALCDATE(Expr2, Ref­D­ate);
Date3 := CALCDATE(Expr3, Ref­D­ate);
MESSAGE(Text000 + Tex­t001 + Tex­t002 + Tex­t003,
Ref­D­ate, Expr1, Date1, Expr2, Date2, Expr3, Date3);
The mes­sage win­dow dis­plays the fol­low­ing text:
The ref­er­ence date is: 05÷21÷96
The expres­sion: CQ+1M-10D returns 07÷20÷96
The expres­sion: -WD2 returns 05÷14÷96
The expres­sion: CM+30D returns 06÷30÷96


“ —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

Appoġġ traduzz­joni: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —
Microsoft Dynam­ics NAV — Kif To: Sib Start Data u Tmiem Data tal Xahar Preċedenti

Lokali / Var­jab­bli Glob­ali:

Isem data­type Sot­to­tip Tul
StartDate Data
End­Date Data

StartDate = data tal-aħħar xahar Bidu.
End­Date = L-aħħar jum tax aħħar xahar.
StartDate: = CALCDATE ( “”<- CM-1M>””); // StartDate = 2012÷01÷08
End­Date: = CALCDATE ( ““CM””, StartDate); // End­Date = 31/08/2012.
CALCDATE

Minn Microsoft Dynam­ics NAV 2009 R2 Għa­jnuna.
Jikkalku­la data ġdida li hija bbażata fuq l-espress­joni data u data ta ref­er­en­za.
NewD­ate: = CALCDATE (Date­Ex­pres­sion [, Data])
para­met­ri
Date­Ex­pres­sion
Tip: Test, Kodiċi, jew Date­For­mu­la
L-espress­joni data jista jkun kwalunk­we tul. -Sek­wen­za huwa inter­pretat mix-xel­lug għal-lemin bl subex­pres­sion wieħed kull dar­ba. Ir-regoli li ġejjin jid­deskrivu l-sin­tassi val­idu ta espress­jon­iji­et data:
· Date­Ex­pres­sion = [<SubEx­pres­sion>] [<SubEx­pres­sion>] [<SubEx­pres­sion>]
· <SubEx­pres­sion> = [<Sign>] <Ter­minu>
· <Sign> = + | -
· <Ter­minu> = <Num­ru> <Unità> | <Unità> <Num­ru> | <Pre­fiss> <Unità>
· <Num­ru> = num­ru sħiħ pożit­tiv
· <Taqsima> = D | WD | W | M | Q | Y (D = jum, WD = week­day, W = il-ġimgħa, M = il xahar, Q = kwart, Y = sena)
· <Pre­fiss> = C (Ċ = attwali)
Dawn ir-regoli ta produzz­joni turi li l-espress­jon­iji­et data tikkon­sisti minn żero, wieħed, tne­jn, jew tli­eta subex­pres­sions. Kull subex­pres­sion jinkludi sin­jal obblig­at­or­ju u ter­minu. Dawn li ġejjin huma xi eżem­pji tipiċi ta ter­mini:
· 30d (30 jum; jikkor­rispondi għal <Num­ru> <Unità>)
· WD2 (week­day num­ru 2; jikkor­rispondi għal <Unità> <Num­ru>)
· CW (ġimgħa kur­renti; jikkor­rispondi għal <Pre­fiss> <Unità>)
Il-kal­en­dar­ju intern ta C / SIDE jib­da nhar it-Tne­jn u jis­piċċa l-Ħadd. Dan ifis­ser li it-tne­jn hija week­day 1 u l-Ħadd huwa week­day 7.
Żball run-time iseħħ jekk l-sin­tassi ta Date­Ex­pres­sion hija żbal­jata.
data
Tip: Data
Uża dan il-para­metru mhux obblig­at­or­ju li jid­definixxu data ta ref­er­en­za. In-nuqqas hija d-data tas-sis­tema attwali.
Jekk inti jħal­li bar­ra dan il-valur mhux obblig­at­or­ja d-data tas-sis­tema attwali qed tin­tuża.