AugForums.com

An Acumatica User Group

  • Free
    • Start Here
    • In-Person Gatherings
    • Power BI Workshop
    • Podcast
    • Rolodex
    • Blog
    • Forums
  • Paid
    • AugSQL
    • GI Course
    • GI Library
    • Consulting
  • Register
Acumatica Forums

By using this website, you agree to our Terms of Use (click here)

Forums
AUG Forums
Acumatica Generic I...
Convert Last Day of...
 
Notifications
Clear all

#AcumaticaTnT Convert Last Day of Month from a Financial Period

 
Acumatica Generic Inquiries & Pivot Tables
Last Post by Michael.Barker 6 years ago
11 Posts
3 Users
1 Reactions
5,891 Views
RSS
Tim Rodman
Posts: 3204
 Tim Rodman
Admin
Topic starter
June 4, 2019 2:07 pm
(@timrodman)
Famed Member
Joined: 10 years ago

I needed to convert a Financial Period in Acumatica to the last day of the month in that Financial Period.

If you look at the End Date field on the Master Financial Calendar (GL201000) screen, you'll see that it refers you to the MasterFinPeriod.EndDateUI field but for some reason Acumatica won't allow me to use that field in a calculation.

So, I came up with a really ugly formula instead. Jotting it down here so I can remember it in the future.

This formula assumes that your Financial Periods are monthly buckets where the first two digits are the month number (01-2019, 02-2019, ... 12-2019) and you are using a Calendar year. This also assumes that you are in the United States and you write dates like a Neanderthal in the format of Month/Day/Year instead of the civilized way of Day/Month/Year.

=DateAdd(DateAdd(CDate(Left([@FinancialPeriod],2)+'/1/'+Right([@FinancialPeriod],2)),'m',1),'d',-1)

I'd love to know if anyone has a better way of doing this.


10 Replies
Tim Rodman
Posts: 3204
 Tim Rodman
Admin
Topic starter
June 4, 2019 2:15 pm
(@timrodman)
Famed Member
Joined: 10 years ago

I wish we had a GetPeriodEndDate function in Generic Inquiry like we do in the Financial Report Writer:

https://www.augforums.com/augforums/acumatica-analytical-report-manager-financial-report-writer/displaying-start-date-beginning-of-period-to-end-date-end-of-period/


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
June 4, 2019 5:46 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

I'm confused. Isn't this what you want?

FinDate from FinPeriod table is what you want. FinDate i am assuming means Finish Date as there is also a corresponding StartDate, being ofcourse the first date of the period. 


Reply
Tim Rodman
Posts: 3204
 Tim Rodman
Admin
Topic starter
June 9, 2019 8:56 pm
(@timrodman)
Famed Member
Joined: 10 years ago

I think FinPeriod.FinDate became MasterFinPeriod.EndDateUI when Acumatica started allowing multiple Fiscal Calendars in the same Tenant.

Are you able to use FinPeriod.FinDate in a calculation like comparing to another date to see if it's on or before that date?


Reply
Royce Lithgo
 Royce Lithgo
(@roycelithgo)
Joined: 6 years ago

Honorable Member
Posts: 557
June 10, 2019 1:35 am
Reply toTim RodmanTim Rodman
Posted by: Tim Rodman

I think FinPeriod.FinDate became MasterFinPeriod.EndDateUI when Acumatica started allowing multiple Fiscal Calendars in the same Tenant.

Are you able to use FinPeriod.FinDate in a calculation like comparing to another date to see if it's on or before that date?

Of course - here's a simple query showing all periods where FinDate is greater than today's date (hard-coded):

(partial results shown)


Reply
Tim Rodman
Posts: 3204
 Tim Rodman
Admin
Topic starter
June 10, 2019 9:02 pm
(@timrodman)
Famed Member
Joined: 10 years ago

Interesting. Seems like they broke it when they introduced MasterFinPeriod.


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
June 10, 2019 9:29 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

I find that really hard to believe. The period table needs to have period start and end dates. FinPeriod also has EndDateUI. That is a different field.

Are you saying that MasterFinPeriod doesn't have FinDate and StartDate?

 


Reply
Tim Rodman
Posts: 3204
 Tim Rodman
Admin
Topic starter
June 14, 2019 8:51 pm
(@timrodman)
Famed Member
Joined: 10 years ago

Here are some screenshots.

 

First, my Master Financial Calendar (GL201000) screen:

 

Second, relevant fields from the MasterFinPeriod table displayed in a Generic Inquiry:


Reply
Michael.Barker
Posts: 28
 Michael.Barker
August 13, 2020 5:14 pm
(@michael-barker)
Eminent Member
Joined: 6 years ago

Hi Tim,

I'm having trouble with the MasterFinPeriod.FinPeriodID schema as the database update removed the FinPeriod table. Now the FinPeriodID field is a Int32 where my reports are calling for a DateTime type. 

I've tried converting to CDate like this: =CDate( DateAdd([MasterFinPeriod.FinPeriodID],'d', -1) ) to no avail.

 

Quote from my trace:

8/13/2020 9:07:40 PM Error:
Can't calculate expression node: 'ReportNode dataItem: '.

PX.Common.Parser.ExpressionException: Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.
   at PX.Common.Parser.ExpressionContext.CheckDateProperty(String method, Object value, Int32 paramIndex)
   at PX.Common.Parser.ExpressionContext.DateAdd(FunctionContext context, Object date, Object interval, Object number)
PX.Common.Parser.ExpressionException: An error has occurred while the DateAdd(Identifier(MasterFinPeriod.FinPeriodID), Const(d), UnaryOp: - (Const(1))) function was being executed:
'Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.' ---> PX.Common.Parser.ExpressionException: Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.
   at PX.Common.Parser.ExpressionContext.CheckDateProperty(String method, Object value, Int32 paramIndex)
   at PX.Common.Parser.ExpressionContext.DateAdd(FunctionContext context, Object date, Object interval, Object number)
   --- End of inner exception stack trace ---
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Reports.Data.SectionNode.a(ExpressionNode A_0)
PX.Common.Parser.ExpressionException: Can't calculate expression part: 'CDate(DateAdd(Identifier(MasterFinPeriod.FinPeriodID), Const(d), UnaryOp: - (Const(1))))'. ---> PX.Common.Parser.ExpressionException: An error has occurred while the DateAdd(Identifier(MasterFinPeriod.FinPeriodID), Const(d), UnaryOp: - (Const(1))) function was being executed:
'Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.' ---> PX.Common.Parser.ExpressionException: Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.
   at PX.Common.Parser.ExpressionContext.CheckDateProperty(String method, Object value, Int32 paramIndex)
   at PX.Common.Parser.ExpressionContext.DateAdd(FunctionContext context, Object date, Object interval, Object number)
   --- End of inner exception stack trace ---
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Reports.Data.SectionNode.a(ExpressionNode A_0)
   --- End of inner exception stack trace ---
   at PX.Reports.Data.SectionNode.a(ExpressionNode A_0)
   at PX.Reports.Data.SectionNode.ProcessItem()
   at PX.Reports.Data.ItemNode.Process(Object dataItem)
PX.Common.Parser.ExpressionException: Can't calculate expression node: 'groupHeaderSection2 (PX.Reports.Data.GroupSectionNode) dataItem: System.Object[]'. ---> PX.Common.Parser.ExpressionException: Can't calculate expression part: 'CDate(DateAdd(Identifier(MasterFinPeriod.FinPeriodID), Const(d), UnaryOp: - (Const(1))))'. ---> PX.Common.Parser.ExpressionException: An error has occurred while the DateAdd(Identifier(MasterFinPeriod.FinPeriodID), Const(d), UnaryOp: - (Const(1))) function was being executed:
'Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.' ---> PX.Common.Parser.ExpressionException: Type mismatch in the argument 1 of the DateAdd() function: The argument must have the DateTime type.
   at PX.Common.Parser.ExpressionContext.CheckDateProperty(String method, Object value, Int32 paramIndex)
   at PX.Common.Parser.ExpressionContext.DateAdd(FunctionContext context, Object date, Object interval, Object number)
   --- End of inner exception stack trace ---
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Common.Parser.FunctionNode.Eval(Object row)
   at PX.Reports.Data.SectionNode.a(ExpressionNode A_0)
   --- End of inner exception stack trace ---
   at PX.Reports.Data.SectionNode.a(ExpressionNode A_0)
   at PX.Reports.Data.SectionNode.ProcessItem()
   at PX.Reports.Data.ItemNode.Process(Object dataItem)
   --- End of inner exception stack trace ---
   at PX.Reports.Data.ItemNode.Process(Object dataItem)
   at PX.Reports.Data.ReportNode.a(Object A_0, Int32 A_1)
   at PX.Reports.Data.ReportNode.a(IDataNavigator A_0, Int32 A_1, ProcessDataHandler A_2)
   at PX.Reports.Data.ReportNode.a(Object A_0, Int32 A_1)
   at PX.Reports.Data.ReportNode.a(IDataNavigator A_0, Int32 A_1, ProcessDataHandler A_2)
   at PX.Reports.Data.ReportNode.ProcessItem()
   at PX.Reports.Data.ItemNode.Process(Object dataItem)
   at PX.Reports.Data.ItemNode.Process(Object dataItem)
   at PX.Reports.Data.ItemNode.Process()
   at PX.Reports.Data.ReportNode.Process()
   at PX.Reports.Data.ReportProcessor.ProcessReport(Report definition)
   at PX.Data.PXLongOperation.<>c__DisplayClass68_0`1.b__0()
   at PX.Data.PXLongOperation.<>c__DisplayClass17_0.b__0()

 

HELP Please!


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
August 16, 2020 8:27 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

You should be using the date fields that are on MasterFinPeriod, either StartDate (1st day of period) or FinDate (last day of period).


Reply
Michael.Barker
 Michael.Barker
(@michael-barker)
Joined: 6 years ago

Eminent Member
Posts: 28
August 17, 2020 12:50 pm
Reply toRoyce LithgoRoyce Lithgo

@roycelithgo - That was it! Thanks so much 🙂


Reply
Tim Rodman reacted
Forum Jump:
  Previous Topic
Next Topic  
Forum Information
Recent Posts
Unread Posts
Tags
  • 12 Forums
  • 2,530 Topics
  • 11 K Posts
  • 9 Online
  • 2,418 Members
Our newest member: Chad Treadwell
Latest Post: Negative/Credit Inventory Value?
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Online Members

  • Johnny Tang
Acumatica Forums

Terms of Use & Disclaimers :: Privacy Policy

Copyright © 2026 · AUG Forums, LLC. All rights reserved. This website is not owned, affiliated with, or endorsed by Acumatica, Inc.

‹›×

    ‹›×