Subject Re: time casting problem...
Author Adam
--- In firebird-support@yahoogroups.com, "Adam" <adam.cirkic@...> wrote:

Another Adam, that is going to confuse me (not talking to myself,
promise).

>
> When I set "StartTime" and "EndTime" variable like const char
> /*"StartTime" = '17:15:00.0000';
> "EndTime" = '18:15:00.0000';*/ it work (I get 5 results), but if I
> have dinamic sign with the same values it doesn't work (I get
> null)....please help me!

You are not assigning them to a char. When you assign a time literal
to a time variable, it is automatically casted.

But you can't just assign a random string to a time variable.

>
> select condition is:
> ...
> cast("Visit"."Time" as time) between cast(:"StartTime" as time)and
> cast(:"EndTime" as time)
>
> This is the code example:
>
> //////////////////////PROCEDURE CODE/////////////////////////////
>
> declare variable "StartTime" char(13);
> declare variable "EndTime" char(13);
>
> ...
>
> /*this don't work!!! I'm shure I have '17:15:00.0000' and
> '18:15:00.0000' as result of previous query*/

Be 100% sure of it, transaction isolation has caught me out more times
than I shall admit on the list. Suspend the value as a temporary
output parameter if you must but be 100% sure.

> "StartTime" = cast(:"StartHour" as char(2)) || ':' ||
> cast(:"StartMinute" as char(2)) || ':' || '00.0000';

You can't use:

StartTime = SomeRandomString;

even if that random string happens to look like a time to a human.

Try

StartTime = cast((cast(:"StartHour" as char(2)) || ':' ||
cast(:"StartMinute" as char(2)) || ':' || '00.0000') as time);


Adam