We have an application that consumes data from Dynamics CRM and do some queries to retrieve data after a specific date and time.
It is important to us to know what clock uses Dynamics CRM to set the date for its records. For example, when it creates a new Opportunity, where the createdon date comes from?
Is the date and time based on the clock of the web server where CRM is running, is it based on the SQL Server where the CRM Database is stored, other?
I've never seen any actual documentation on this question. I can deduce the following from looking at SQL traces and some decompilation of CRM server DLLs.
I'm not sure there is a single way that date/time values get generated in Dynamics CRM.
For example, there is a stored proc to create a WebResource which uses SQL Server's function to get utc time. In that case the time will be clock time of the server hosting SQL.
This is not true for creating/updating entity records. In this case the time is passed as part of the INSERT
command. I do not believe CRM is doing a call to get SQL Server's time first, thus this time is coming from the CRM web front-end server (or the async server if the Create/Update operation is taking place asynchronously.) .NET provides the UTC time value, I do not believe there is an explicit conversion of time values taking place for populating these values on Create and Update. There is an explicit action to remove the milliseconds part.
If you use OverrideCreatedOn
then the value is completely up to you (so long as it's within the CRM acceptable range), but it will cut off the milliseconds.