Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

SQL VS NAV TIME DIFFERENCE

(0) ShareShare
ReportReport
Posted on by 100

SQLvsNAVtimeDiff.bmpHi

I have nav database with BC spring 

Actually I am pulling some data from another database to NAV database using SQL query

It is showing correct date-time in SQL list but the same table in nav is showing different time

Please find attached document and advice

Warm Regards

Krishna

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: SQL VS NAV TIME DIFFERENCE

    When you perform the INSERT into the NAV table, you need to convert the datetime value to UTC and save the UTC value to the NAV datetime field.

    You can do as follows in T-SQL to convert a datetime to UTC:

    SELECT DATEADD(second, DATEDIFF(second, GETDATE(), GETUTCDATE()), YOUR_DATE);

  • KrisMuthy Profile Picture
    KrisMuthy 100 on at
    RE: SQL VS NAV TIME DIFFERENCE

    Ok but

    In SQL server the date and time ok.  

    when open nav table the data shows dfferent

    SELECT column_name,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), column_name)  AS ColumnInLocalTime from table1

    the above query good  and working fine

    but in NAV I am getting time is wrong

    Warm regards

    Kris

  • RE: SQL VS NAV TIME DIFFERENCE

    Hi

    As i mention before, "The reason is that a datetime in SQL is saved as a universal time that also includes the timezone. The date in NAV shows the datetime in your timezone."

    This is according to server configuration, but you can try do this:

    SELECT column_name,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), column_name)  AS ColumnInLocalTime from table1

    With this query, you can see the correct time (local)

    Christian Mendoza.

    Best regards.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans