Hello, 

I am currently working on Version 10.0.828.0.

When I upload a file, the CurrDateTime is not returning the currdatetime but the time I loaded the page.

Is there any way I can get around this or fix it? This is not happening anywhere else.

Hi Matt,

Not sure what you mean. CurrDateTime() returns the date and time of the server. On a Personal Environment or another OutSystems cloud environment, this is usually UTC.

You talk about uploading a file - what does this have to do with the current date/time?

Hi Kilian,

I have a file entity with a CreatedOn attribute which is a DateTime. I brought up the fact that I’m uploading a file because this is the only occurrence where this problem happens. For example, I uploaded a file and assigned the CreatedOn to CurrDateTime() but it returned 7 minutes ago(the time I opened the page). 

I hope this helps.

Hi Matt,

Are you assigning the CurrDateTime() in the Preperation of the Screen instead of in the Screen Action of the Upload? That's the only reason I could think of for a DateTime to have the value of the time you opened the Screen.

Also, have you debugged the Screen to see what is going on?

The CurrDateTime() is the default value of the CreatedOn attribute so it should be assigned as soon as the file is created.


I have debugged the screen and I am receiving the wrong value from the CurrDateTime function.

Solution

Hi Matt,

I didn't even know that CurrDateTIme() could be the default value of an Attribute! But apparently it is. Not very useful though: what happens is that the Default Value of an Attribute is set at the moment the Variable is created: which in this case means as soon as the Screen is opened. You can do two things:

  1. Which I would suggest, is to assign CurrDateTime() to the variable (and removing the default value), or, better, expose the Entity Read Only and use a proper CRUD Action;
  2. Put the Variable as a Local Variable to the Screen Action instead of the Screen.
Solution

Hi Kilian,

Thank you for help. I decided to take the default value off and assign it in my CRUD action. This worked. It is still strange that I use the functionality that I had for other entities but this problem only occurred here.

Hi Matt, perhaps in those cases the Variable wasn't a "global" Screen Local Variable but a Local Variable of a Screen Action or Action?