DT2UTC
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.
Comments
Some remark:
I worked with function FORMAT(DT,0,9) in different version and know that parameter 9 exist begin form version NAV 3.70B
Best Regards
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
Version 1.01:
Take care of blank dates
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.
Great work! Good idea to use xml-Format "9".
Just 2 question to this:
- I assume this function takes care of the current locale settings concerning daylight saving zone and dates. Is that correct?
- What I don't understand is why currentdatetime returns just that (current date and time of the system) but if stored to a datetime field it is converted to utc. Is that correct, and do you know what could be the reason?
Thanks again and thanks in advance for your comment to this.
Thomas
Yes, Navision/Dynamics NAV takes care of the current locale settings concerning daylight saving zone and dates.
If one company has users placed around the world, and they want a central log, then they have to log UTC date and time, otherwise the log will be mix-up if every user, was using they local time, and not a central time, when sorting on date time field.
Flemming
Flemming R. Petersen
Denmark
UTC_Text := FORMAT(DT,0,9);
IF NOT EVALUATE(YYYY,COPYSTR(UTC_Text,1,4)) THEN
EXIT(DT);
IF EVALUATE(MM,COPYSTR(UTC_Text,6,2)) THEN
EXIT(DT);
IF EVALUATE(DD,COPYSTR(UTC_Text,9,2)) THEN
EXIT(DT);
D := DMY2DATE(DD,MM,YYYY);
Should be
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
You are totally right, new version 1.02 ready.
Flemming R. Petersen
Denmark
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
Version 1.02:
Fix bug Evaluate in version 1.01
Version 1.01:
Take care of blank dates
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.
Just a last question:
You note that "You must always enter datetimes as local time". Is entering through a GUI and storing through a codeunit the same? And last but not least: If storing through a codeunit and reading againg thorugh a codeunit to a variable: what value is stored in the variable (local datetime or utc datetime)? Sorry, maybe a stupid question.
Thanks anyway
Thomas
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
Version 1.03:
New version 1.03 of DT2UTC, with 2 functions, DT2UTC and UTC2DT, now it is using settings from register DB to convert.
Version 1.02:
Fix bug Evaluate in version 1.01
Version 1.01:
Take care of blank dates
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
Version 1.04:
Fix. date bug when passing midnight!
Version 1.03:
New version 1.03 of DT2UTC, with 2 functions, DT2UTC and UTC2DT, now it is using settings from register DB to convert.
Version 1.02:
Fix bug Evaluate in version 1.01
Version 1.01:
Take care of blank dates
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.
Function to returns the UTC date time from a DateTime field.
The datetime is stored in the database as Coordinated Universal Time (UTC). UTC is the international time standard (formerly Greenwich Mean Time, or GMT). Zero hours UTC is midnight at 0 degrees longitude. The datetime is always displayed as local time in Dynamics NAV. Local time is determined by the time zone regional settings used by your computer.
You must always enter datetimes as local time. When you enter a datetime as local time, it is converted to UTC using the current settings for the time zone and daylight saving time.
This function returns the UTC date time.
Version 1.05:
Fix. date bug.
Version 1.04:
Fix. date bug when passing midnight!
Version 1.03:
New version 1.03 of DT2UTC, with 2 functions, DT2UTC and UTC2DT, now it is using settings from register DB to convert.
Version 1.02:
Fix bug Evaluate in version 1.01
Version 1.01:
Take care of blank dates
http://www.mibuso.com/dlinfo.asp?FileID=957
Discuss this download here.