Get the App
SLTechnology News&Howtos  ›  Database  › 

What if the datediff function causes an overflow and the number of the date part used to separate two date / time instances is too large?

Shulou Source: shulou.com Published: 2022-05-31 13:39:45 10月02日 Update

The datediff function causes an overflow and what to do if the number of the date part used to separate two date / time instances is too large. To solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Execute the script that checks for alwayson synchronization:

SELECT availability_mode_desc

Role_desc

Replica_server_name

Last_redone_time

GETDATE () now

DATEDIFF (ms, last_redone_time, GETDATE ()) diffMS

FROM ((sys.availability_groups AS ag

JOIN sys.availability_replicas AS ar ON ag.group_id = ar.group_id

)

JOIN sys.dm_hadr_availability_replica_states AS ar_state ON ar.replica_id = ar_state.replica_id

)

JOIN sys.dm_hadr_database_replica_states dr_state ON ag.group_id = dr_state.group_id

AND dr_state.replica_id = ar_state.replica_id

Error report:

The datediff function caused an overflow. The number used to separate the date part of the two date / time instances is too large. Try using datediff with lower precision in the date section.

1. It may be a date with a null value

2. Maybe the difference between the two dates is too far.

After inspection, it was found that the difference between the two dates was too far.

The time of last_redone_time is too different from that of GETDATE ().

Indicates that there is a library that has not been updated for a long time, so the value of last_redone_time has not changed for a long time.

Update the data in that library, the synchronization script is normal.

The answer to the question about the overflow caused by the datediff function and the large number of the date part used to separate the two date / time instances is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: Date two time part function instance number question too far how to do data more script long time synchronization help update check answer easy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL Docker MariaDB OPPO Reno