Skip to main content
2 of 2
Commonmark migration

Not the best tool for the job.

I frequently use database systems strictly for date-time calculations. Because they are really good at it. A Code Review regular once said:

Never calculate date time by hand. This rule is more important than not using GoTo statements...

Database connectors for Java are easy to make, and you just need a few stored functions/procedures to do the job more accurately than any human could.

Example?

SELECT DATEADD(MINUTE, 29723947, CURRENT_TIMESTAMP);
-------------
2071-12-30 17:05:59

Another?

DECLARE @FallOfBerlinWall DATE = '1990-10-03';
SELECT DATEDIFF(SECOND, @FallOfBerlinWall, CURRENT_TIMESTAMP);
--------- 
780372479

TL:DR;

Don't calculate date-time by hand.

Phrancis
  • 20.4k
  • 6
  • 68
  • 154