I have no doubt that what I am about to ask is a head-slapper. Forgive me, I am an AX newb. I have searched the limited resources I can find and have not found an answer to what should be a very simple question. Please help.
I am writing a job in the AOT. It is literally three lines. I want to delete all activities prior to 6/1/2008. Below is the code:
smmActivities act;
;
delete_from act where act.StartDateTime <= “06/01/2008”;
When I compile this I get an error that the Operand types are not compatible with the operator.
At first I thought that it was not converting my date string to a DateTime data type. But changing the criteria to act.StartDateTime <= today() generated the same error. It is a data type issue because today() <= today() compiles fine.
So the question is, how do I convert my date string to the proper data type?
Thanks msz_. I greatly appreciate the help! Unfortunately for me, the mkDate() function converts to a Date data type. The StartDateTime field in smmActivities is a DateTime data type. I am not sure when they introduced this. We are on the bleeding edge with DAX2009. (We are currently still doing gap/fit analysis prior to implementation.)
…I just got it. There is a function called str2datetime. That did the trick. Thanks again.
delete_from act where act.StartDateTime <= str2datetime(“06/01/2008”, 213);
Parameter explanation…
text
The date/time string to be converted into a utcdatetime.
sequence
A three digit number that describes the sequence of the date components in the text parameter. Each component is represented by a digit:
1 – day
2 – month
3 – year
For example, YMD is 321.
All valid values contain each of these three digits exactly one time.