how to get Server date?

yanfengyanfeng Member Posts: 2
edited 2008-09-22 in NAV Tips & Tricks
Navison Install use Client\server, DB is Microsoft SQL, in client , how do i can get Server date?

Comments

  • saikiransaikiran Member Posts: 22
    Hi,

    what do you need it for? I do not know any way to get the server date at the client in Navision.
    There might be some workarounds.
  • xinyerxinyer Member Posts: 6
    yanfeng wrote:
    Navison Install use Client\server, DB is Microsoft SQL, in client , how do i can get Server date?

    Hi brother, for this, you can set in Windows 2003 domain policy, I guess so.
  • kinekine Member Posts: 12,562
    creat this view on the ms sql in your Navision Database:

    CREATE VIEW dbo.ServerDateTime_View
    AS
    SELECT '' AS PK, GETUTCDATE() AS ServerDateTime
    ORDER BY ''

    Create new table in Navision with same name as the view (you can use another
    name in the view),
    create two fields:

    1 PK Code 20
    2 ServerDateTime DateTime

    Set properties:
    DataPerCompany = No
    LinkedObject = Yes

    Save the table. If you make SDT.GET; (SDT is variable of type Record for
    your new table) you have in field SDT.ServerDateTime the server date and
    time...

    The field PK is there only as simulation of Primary key to be able to make
    GET for this table...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bestianhowbestianhow Member Posts: 120
    hi kine, how the navision table trigger or link together with the SQL Server view dbo.ServerDateTime_View? May u explain the concept?

    Thank you very much =D>


    Kok Keong
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    It's explained in this thread: http://www.mibuso.com/forum/viewtopic.php?t=5906 (read answers from Waldo and fb).
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • bestianhowbestianhow Member Posts: 120
    thanks Luc Van Dyck and kine.
  • fbfb Member Posts: 246
    Or, if tables are hard to find, you could try a little Automation code... (adoRecSet is 'Microsoft ActiveX Data Objects 2.8 Library'.Recordset)
    CREATE(adoRecSet);
    adoRecSet.open(
      'SELECT CONVERT(char(25), GETDATE(), 126) AS ServerDateTime',
      'Provider=SQLOLEDB;Server=(local);Trusted_Connection=Yes');
    theDateTimeString := FORMAT(adoRecSet.Fields.Item(0).Value);
    CLEAR(adoRecSet);
    
    MESSAGE(theDateTimeString);
    
    Of course, you must change 'Server=...' to the name of your SQL server...
  • krikikriki Member, Moderator Posts: 9,094
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.