开发者

Firebird 2.1 TIMESTAMP arithmetic and civil intervals

My understanding is that, in keeping with Interbase v6, Firebird 2.5 does not support the SQL-92 INTERVAL keyword. At least, so suggests this reference and my repeated SQLCODE -104 errors trying to get INTERVALs to work under Firebird's isql(1).

How, then, do I account for the irregularities in our开发者_如何学Python civil reckoning of time -- months aren't uniformly long, nor are days with savings time and leap adjustments, not to mention the year of confusion, etc. -- when performing TIMESTAMP arithmetic under Firebird 2.1?

How can I easily determine "one month earlier" or "one week later" than a given TIMESTAMP? How about "one day later" or "two hours before"?


You may use the DateAdd() and DateDiff() built-in functions.
Alternatively you may also use classic date arithmetic.


If this isn't implemented in Firebird, maybe you could do it through the technology calling your sql server, and get the resulting timestamp ? I know it can be quite easily done in Java or .Net


You can also use the functions of the external UDF fbudf.dll


There is a nice external UDF named rFunc: http://rfunc.sourceforge.net/, it has nice Date functions like DaysBetween and IncDate(d, i1, i2, i3) and many more


  1. Subtract one day from timestamp date in a loop until month has changed.
  2. Subtract one day from timestamp date in a loop until day has changed to SUNDAY.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜