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

Hi,

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

Regards,

S.kuppusamy.

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

-Rajee

you can use built in funtion as below:

1)date
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;
pause;
}
2) time
static void timeNowExample(Args _arg)
{
int i;
;
i = timeNow();
print "The number of seconds since midnight is " + int2Str(i);
pause;
}

  1. use Time to str function to convert time in second form your desire format.
    // Returns the text string 05:01:38.
    time2Str(18098,1,1);
    // Returns the text string 05:01:38 am.
    time2Str(18098,1,2);
    // Returns the text string 05 01 39.
    time2Str(18099,3,1);
    // Returns the text string 05/01/39 am.
    time2Str(18099,5,2);

  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?

HI

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.

BR,

KIK

Hi,

I have found few links … these may helps :

http://kashperuk.blogspot.com/2010/02/utcdatetime-in-dynamics-ax-2009.html
http://dynamics-ax.blogspot.com/2010/03/dynamics-ax-2009-x-thread-development.html

Best Regards,

KIK

Hi Mehul Thacker,

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

Thanks and Regards,

S.Kuppusamy.

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.

Regards,

S.Kuppusamy.

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: http://www.axaptapedia.com/Current_Time 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 http://msdn.microsoft.com/en-us/library/aa882882.aspx

Hi Daniel,

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

Regards,

S.Kuppusamy.

Hi Kranthi,

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

Regards,

S.Kuppusamy.

Hi

Use Systemdateget()

timenow() functions

kishore

Hi everyone,

I have one query. How could i get the date in my code which i passed in the date field of my form.like 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

Pranav

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();

Thanks

Pranav

How to display date automatically in table level.

Thanks in advance.