delphi - Firebird equivalent to start and end of the day -


i need exchange current_date in firebird stored proc delphi equivalent of startoftheday , endoftheday.

delphi's startoftheday returns 18.08.2017:00.00.00.001, endoftheday returns 18.08.2017:23.59.59.999.

how in firebird ?

how start of day date input?

you can write command this:

select dateadd(millisecond, 1, cast(current_date timestamp)) rdb$database 

in procedure can be:

create procedure myprocedure declare variable daystart timestamp; begin   daystart = dateadd(millisecond, 1, cast(current_date timestamp));   ... end 

it casts date value timestamp (because dateadd function sensitive input data type) , adds 1 millisecond value. today should (but don't think match delphi function result):

18.08.2017, 00:00:00.001 

how end of day date input?

similarly start of day, can write command end of day:

select dateadd(millisecond, -1, cast(current_date + 1 timestamp)) rdb$database 

in procedure:

create procedure myprocedure declare variable dayend timestamp; begin   dayend = dateadd(millisecond, -1, cast(current_date + 1 timestamp));   ... end 

this 1 adds 1 day given date, casts timestamp , subtracts 1 millisecond it. today should return (which matches mentioned delphi function):

18.08.2017, 23:59:59.999 

how date timestamp input?

if input of timestamp type time portion specified, first cast date rid of time portion. example day start timestamp value:

select dateadd(millisecond, 1, cast(cast(current_timestamp date) timestamp)) rdb$database 

or in stored procedure:

create procedure myprocedure  declare variable dayend timestamp; declare variable daystart timestamp; declare variable datetime timestamp; begin   datetime = current_timestamp; -- has time portion if not executed @ midnight   daystart = dateadd(millisecond, 1, cast(cast(datetime date) timestamp));   dayend = dateadd(millisecond, -1, cast(cast(datetime date) + 1 timestamp));   ... end 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -