Subject | Re: [ib-support] udf crashes firebird |
---|---|
Author | Ivan Prenosil |
Post date | 2003-05-20T15:03:47Z |
From: "Nick Upson" <uebridger@...>
The comment in your UDF said:
"fn_dowi() return the day of today as integer, Monday = 1, Sun = 7, etc"
so I thought you would prefer 7 for Sunday.
Ivan Prenosil
[ I am looking for a job: InterBase - Firebird - Delphi - C - fulltext db - and more ... ]
Ivan.Prenosil@...
http://www.volny.cz/iprenosil/interbase
> > > using FB1.0.2 but I can't get EXTRACT(WEEKDAY FROM 'today'- 1) + 1 to'today' is in apostrophes, hence it is not reserved word, but string literal of type char(5).
> >work
> >
> >That's because 'today' is string - you can't subtract numbers from string.
> >Either cast it to date (or timestamp, so it can work with dialect-1 too):
> >
> > EXTRACT(WEEKDAY FROM CAST('today' AS TIMESTAMP) - 1) + 1
> >
> >or better yet use CURRENT_DATE or CURRENT_TIMESTAMP instead:
> >
> > EXTRACT(WEEKDAY FROM CURRENT_TIMESTAMP - 1) + 1
>
> I thought today was a reserved word for a date, learn something new
>Right, but without -1 and +1 you will get 0 (zero) for Sunday.
> why the -1 and +1 on the end? without them I get a result of 2 for today,
> which is correct.
The comment in your UDF said:
"fn_dowi() return the day of today as integer, Monday = 1, Sun = 7, etc"
so I thought you would prefer 7 for Sunday.
Ivan Prenosil
[ I am looking for a job: InterBase - Firebird - Delphi - C - fulltext db - and more ... ]
Ivan.Prenosil@...
http://www.volny.cz/iprenosil/interbase