Dear Friends, Could please let me know how we could get the calendar week of a particular date. Example: Today (7.7.2022) is the 27th Week of the year
"Why I was forced to find solution to this Query ??" ...... .Because the date in your query is very important to me. As per Calendar it is 28th week of the year. As first week of the year consists of one date only i.e 1st January (Saturday) Second week starts with 2nd January. If you ignore actual weeks as per calendar then your week number is correct... and accordingly following code will work: Code: [#Menu : Gateway of Tally] ; Add : Item : After : @@locIndentUtilities : @@LocTxoTools Add : Indent : After : @@locIndentUtilities : @@LocTxoBlank Add : Key Item : After : @@LocTxoBlank : @@TxoWeekOfYear : W : Alter: TxoWeekOfYear Add : Indent : After : @@TxoWeekOfYear : @@LocTxoBlank [System : Formulae] LocTxoTools : "Taxo" LocTxoBlank : "" LocTxoBlank1 : "" TxoWeekOfYear : "Taxo- Get Week of Year" [Report :TxoWeekOfYear] Form : TxoWeekOfYear Title : "Taxo- Get Week of Year" [Form: TxoWeekOfYear] ;Width : 25 ;40% Screen ;Height : 16 ;% Screen Full Height : No Full Width : No Option : Small Size Form Part : TxoWeekOfYear [Part : TxoWeekOfYear] Line : TxoWeekOfYear Line : TxoWeekOfYearDis [Line : TxoWeekOfYear] Left Field : TxoWeekDate Right Field : TxoWeekNo [Line : TxoWeekOfYearDis] Left Field : TxoWeekDateDis Right Field : TxoWeekNoDis [Field : TxoWeekDate] Use : Medium Prompt Set as: "Enter Date" [Field : TxoWeekNo] Use : Uni Date Field On : Accept: Yes: Call: TxoGetWeekOfYear On : Accept: Yes: Field Accept Width : 12 [Field : TxoWeekDateDis] Use : Medium Prompt Set as: "Week of Year" Style : Normal Bold [Field : TxoWeekNoDis] Use : Number Field Width : 12 Set : ##vWeekOfDay Set Always : Yes [System : Variable] vWeekOfDay : 0 [Variable: vWeekOfDay] Type : Number [Function: TxoGetWeekOfYear] Variable : vDate : Date : #TxoWeekNo Variable : vNumWeek : Number Variable : vYearBeg : Date Variable : vMonthBeg : Date Variable : vUpToDays : Number Variable : vmonth : Number 100 : Set: vMonth : $$MonthOfDate:##vDate 200 : Set: vMonthBeg : $$MonthStart:##vDate 300 : While : NOT ##vMonth = 1 310 : Set: vMonthBeg : $$PrevMonth:##vMonthBeg ; 320 : Log: ##vMonthBeg 330 : Set: vMonth : ##vMonth-1 400 : End While ; 500 : Log: ##vDate ; 600 : Log: ##vMonthBeg 700 : Set: vUpToDays : ##vDate-##vMonthBeg+1 ;IF ##vMonth in (1,2,3) Then ;-+1 Else ##vYearBeg:##vDate ; 800 : Log: ##vUpToDays 900 : Set: vNumWeek : $$RoundUp:(##vUpToDays/7):1 950 : Set: vWeekOfDay : $$Min:52:##vNumWeek