How to display Current date and time by coding in X++ and for every 12.00 pm, check box should check automatically?


Greetings. How to display Current date and time by coding in X++ and for every 12.00 pm, check box should check automatically?



If i’ve understood rit,think you can run a ‘batch’ for ur requirement


you can use built in funtion as below:

static void date2StrExample(Args _arg)
date d = today();
str s;
s = date2Str(d, 123, 2, -1, 2, -1, 2);
print "Today’s date is " + s;
2) time
static void timeNowExample(Args _arg)
int i;
i = timeNow();
print "The number of seconds since midnight is " + int2Str(i);

  1. use Time to str function to convert time in second form your desire format.
    // Returns the text string 05:01:38.
    // Returns the text string 05:01:38 am.
    // Returns the text string 05 01 39.
    // Returns the text string 05/01/39 am.

  2. finally using 1,2 & 3 you can get date&time.
    now use logic to applay this time & date to checkbox.

Hi Rajee,

Thanks for your information. Could you be more specific about it?


Using getSystemDateTime(); function you can get current datetime of system. But you will get utcDatetime not based on region. You can get time by region wise by using different factions. You can find from system document.

I think you can achieve the requirement by using threads and DateTimeUtil::getSystemDateTime();

I hope this helps.




I have found few links … these may helps :

Best Regards,


Hi Mehul Thacker,

Thanks for your information. It is very useful for me now.

Thanks and Regards,


which check box you are talking about?

Hi Kranthi,

Checkbox may be NoYes enum type of a table field or form control. My requirement is I will need to have a checkbox in a form and for every 12.00 pm of a day, checkbox should be checked automatically. I was told to do it using run base framework. Help me out in this.



Does this mean that every day you create a new record in a table which should be automatically checked at noon regardless if the form is open or not? If the record is updated with a batch job and the forum is running, I doubt that the checkbox would be updated without a refresh on the forum. Maybe you would want to have a timer on the form to check and refresh the box once it is noon?`

I had a little fun playing with the current time here: This shows different ways of getting the current utc time on the client, server or elsewhere.

If the check box is form control and not a data base field - you cannot update it.(you can update it when you open the form but i think which is not your requirement)

If you want the data base field to be updated automatically you need use RunBasebatch frame work.(you need to write a class which extends the RunBaseBatch)

See Tutorial_RunbaseBatch class for more info.

and go through this link also

Hi Daniel,

Thank you for your response. Let me visit this link and do.



Hi Kranthi,

Thank you for your response. I’ll use run base batch.




Use Systemdateget()

timenow() functions


Hi everyone,

I have one query. How could i get the date in my code which i passed in the date field of my for ex, for any string field i can get the value of that field to my code by

“My Variable” = this.valuestr();

but its not working in case of Date, i am not able to get the date value which i pass to my form.

Please suggest some solution.

Thanks& Regards


HI everyone,

I have solved the issue, Actually i am using field name as “Date” that’s why Ax can’t identify the field name, so i changes the Date to ActiveDate & its working.

“MyVariable” = ActiveDate.valuestr();



How to display date automatically in table level.

Thanks in advance.