Server date

jpk4077jpk4077 Member Posts: 9
Hi,

Is thr any way to get the dae and time of navision or sql server.
Workdate gives me the workdqate set by user, today gives me the date/time on client PC. I can do it using dll or select getdate() in code etc. but both of these introduce external dependencies which I wld like 2 avoid.

Tx JPK

Comments

  • g_dreyerg_dreyer Member Posts: 123
    Hi JPK,

    This will require some advanced concepts....

    Create a view on SQL Server that selects the date/time.
    Create the same table (same name/structure, linked=yes, per company=no) in navision to link it to the view.

    The result should be that when you query the table, the time from the server.

    Cheers,
    Gus
  • Rob_HansenRob_Hansen Member Posts: 296
    Another option (that I just thought of - I have not done this) would be to use the application server for this purpose. This would be fairly straightforward:

    1. Add new "Server Date" and "Server Time" fields in the company information table or some other setup table.
    2. Create a new codeunit with a timer event. On each trigger of the timer (every minute) update the new fields.
    3. Trigger the application server with a custom startup parameter to launch this codeunit.

    With the application server running (presumably) on the server, this should accomplish the desired goal - your logic could then read these fields to get the server date/time. In a multi-company scenario you could update a single company's company information table and execute a CHANGECOMPANY to it to read the values when running routines in other companies (or use some table not set up as DataPerCompany).
  • jpk4077jpk4077 Member Posts: 9
    How do v link sql tables with navision tables and do things like retreive data from views etc?

    Have never worked on Navision App server so dunno much abt it.

    Pls advise on the first issue of linking tables in Navision.

    Tx JPK
  • g_dreyerg_dreyer Member Posts: 123
    Firstly let me know the following....
    Do you know how to create views in a database on a SQL Server? I.e. using Enterprise manager.

    If you know how to do that, then the rest is simple.

    Open Enterprise manager and go to the views...
    You create your view, let's say v_ServerDateTime, which does a select query to get the date and time, make sure your columns are date and time (you will probably need to apply formatting so that the time only displays time).

    Now you can open navision....
    Next you create a table in Navision called v_ServerDateTime, create the two fields called server_date, server_time. Edit the properties of the table (go on the first blank line, view | Properties). Make sure that you change the property to linked table = yes, and data per company = no.

    You should be able to run the table, and it should return the correct date and time as per the server.

    Viola!!! (unless I forgot a step somewhere).

    Cheers,
    Gus
  • SujaSuja Member Posts: 46
    How to get the date format been used in the server?
Sign In or Register to comment.