Dear Friends,
I want to add two view computed column to get the month and year from the CreatedDateTime field in ax 2012 R3.
Can someone suggest the sample code?
Regards
Martin
T-SQL has MONTH() and YEAR() functions for this purpose.
Hi Martin,
In order to achieve what you want, you can use below code:
public void Date() { date createdDateTime; ; createdDateTime = DateTimeUtil::date(this.createdDateTime); this.Month = mthofyr(createdDateTime); this.Day = dayofmth(createdDateTime); this.Year = year(createdDateTime); }
I am aware that Month() and Year() function is available in sql. My doubt is how add computed column for month and year in AOT view. Please suggest the sample code
Hello Hossein,
I am aware of this code. My concern is how to create a computed column for Month and Year in AOT View from CreatedDateTime field.
If you know which T-SQL functions you should use, then what exactly do you need from us? Does it mean that you don't know how to write computed columns at all and you're looking for an introduction, or do you have any particular problem?
Maybe seeing a code example will help you:
private static str yearSql() { str fieldIdent = SysComputedColumn::returnField(tableStr(YourView), identifierStr(DsName), fieldStr(YourTable, YourField)); return strFmt('YEAR(%1)'), fieldIdent); }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,004
André Arnaud de Cal... 857 Super User 2025 Season 2
Sohaib Cheema 548 User Group Leader