Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:55:36+00:00 2026-06-15T14:55:36+00:00

I have to synchronize my local date and time with the same date and

  • 0

I have to synchronize my local date and time with the same date and time returned from the database.

The sql:

select first 1 CURRENT_TIMESTAMP from RDB$DATABASE

This SQL command returns the current date and time at the database server.

Now, I need to cache this and provide the correct time based on the local diff.
The problem is that the local date and time can be changed again.

How can I do this to garantee the correct date time without execute the SQL again?


I found a solution:

var
  SQLTimestamp: TDateTime=0;
  LocalTimestamp: TDateTime=0;

function SysUpTime : TDateTime;
var
  Count, Freq : int64;
begin
  QueryPerformanceCounter(count);
  QueryPerformanceFrequency(Freq);
  if (count<> 0) and (Freq <> 0) then
  begin
    Result := Count / Freq;
    Result := result / SecsPerDay;
  end
  else
    Result := 0;
end;

function RealTime: TDateTime;
var
  queryTime, dbTime: tdatetime;
begin
  if SQLTimestamp = 0 then
  begin
    queryTime := SysUpTime;
    dbTime := // SQL QUERY EXECUTION
    queryTime := SysUpTime - queryTime;

    LocalTimestamp := SysUpTime;
    SQLTimestamp := dbTime + queryTime;
  end;

  Result := SQLTimestamp + (SysUpTime - LocalTimestamp);
end;

Now my question is: QueryPerformanceCounter and QueryPerformanceFrequency has the same limitation as GetTickCount?

 The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days. 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:55:38+00:00Added an answer on June 15, 2026 at 2:55 pm

    What does any cache do ? It gives you a ready-made result if some defining conditions still hold, or re-query/re-calculate result if they changed.

    That is what you cache have to do as well. Just re-execute the query if the local time was overrode and use the cache while it is continuous.

    Do re-execute the query, just do it only when you need it rather than on every attempt. http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms725498.aspx

    Now what i’d really like to know what would you do if the server’s clock would be changed, not the local one. Maybe you’d really install separate time-syncing service along wit hdatabase server?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a saved SQLCompare project which I use to synchronize my local database
I have this problem when i try to synchronize a observable list with listbox/view
I have some SVN projects with this folder structure project/trunk/ project/branches/1.x project/branches/2.x project/branches/3.x First
I have a WPF app that from time to time needs to perform a
I need to synchronize appointments of an online database and a local database. That's
I am trying to sync remote SQL database with local SQL database using microsoft
It is the first time I work with this kind of application. Very little
I need to have ALWAYS a background service that will synchronize my Android application
I am trying to synchronize several CABasicAnimations with AVAudioPlayer . The issue I have
I have a web application that synchronizes with a central database four times per

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.