문제

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 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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top