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
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
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); }
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.
Regards
Martin
Hi Martin,
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
Regards
Martin
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); }
T-SQL has MONTH() and YEAR() functions for this purpose.
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,321
Most Valuable Professional
nmaenpaa
101,156