Hi:
I have a "staging" table where I have an outside process write records into this table. The table is then processed by a NAV report to import some data.
I am in SQL Management Studio and I run the following command:
UPDATE [StagingTable] SET [ImportDateTime] = '09/23/2009'
Then, if I display the records in SQL Mgt Studio, it shows the [ImportDateTime] as "2009-09-23 00:00:00.000" - just as I would expect it.
However, if I go into NAV and display the same table, the ImportDateTime field shows as "09/22/09 05:00:00PM"
Now, I know what the difference is. We are in Los Angeles, so we are Universal Time (UTC) minus 7 hours, and our servers are aware of that.
So, one of my questions is how can I, in native SQL, tell my update statement to update the table with the local time instead of the UTC time? Even if I use a SQL function such as "current_timestamp", the same thing occurs. Will it be necessary to do UCT conversion to get the two times to display the same?
Thx
Ron
Ron
0
Comments
NAV 3.60 database under NAV 5.0SP1 client
SQL 2005
Ron
To test it out what you must save into the field, Create a record using NAV and then check in SQL what was written.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I know that a when date in NAV is entered, it is stored as the UTC value - that is not my primary concern.
My question is, I want to insert a date using code outside of NAV but have the same date/time value as when I insert a value using NAV. For example, if the current date and time is 9/23/09 11:55am I write CAL code in a NAV object:
"Transaction Date" := CURRENTDATETIME
Then if I look at the value of the field in NAV it will show 9/23/09 11:55am. If I look at the value of the field in SQL Mgt Studio it shows 9/23/09 4:55am.
However, if I update the value in SQL
Update <tablename> SET [Transaction Date] = current_timestamp
Then if I look in NAV, the value of the field is 9/23/09 8:55pm and the value in SQL is 9/23/09 11:55am.
This applies even if I use a manually entered date, e.g. in CAL if I say "Transaction Date" := CREATEDATETIME(092309D,1155am) it stores it the same as above.
Ron
DATETIME format in NAV is to my opinion useless. I walked into the same problem as you do.
The following is from the help of NAV on DATETIME. In daylight saving period your dates display one hour different. I fixed it by storing the date in as a biginteger and calculated from 1/1/1970T0:00:00
Hope this helps.
Regards
Mark
a. Create separate date and time fields
b. Write the SQL code to convert the current date/time to local time before it inserts it.
Ron
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
GetDate works - it will display the same time in SQL and NAV, e.g.
UPDATE [StagingTable] SET [ImportDateTime] = GETDATE()
But if I want to insert a SPECIFIC date in SQL, it appears I have to use a calculation to take that date date and add 7 hours, e.g.
UPDATE [StagingTable] SET [ImportDateTime] = dateadd(hour,7,'09/01/2009')
If I do this, inside NAV, the date field will display as '09/01/09 12:00am' instead of '8/31/09 5:00PM'.
Mainly the part about ISO 8601 Format:
# YYYY-MM-DDThh:mm:ss[.nnnnnnn][{+|-}hh:mm]
# YYYY-MM-DDThh:mm:ss[.nnnnnnn]Z (UTC, Coordinated Universal Time)
You can try to enter the date and time as
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.