New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add builtin functions FIRST_DAY and LAST_DAY [CORE5620] #5886
Comments
Commented by: Omacht András (aomacht) Don't forget about leap years. LAST_DAY('2000-02-05') -- 2000.02.29 If we already need it, I suggest to publish it as function: IS_LEAP_YEAR(integer) IS_LEAP_YEAR(2000) -- 1 or true |
Commented by: @AlexPeshkoff OF WEEK may be also useful sometimes |
Commented by: @mrotteveel Of WEEK might be problematic: |
Commented by: @asfernandes AFAIK there is already EXTRACT(WEEK ...) so rules could be the same. |
Commented by: @asfernandes And there is this warning in our docs: ---- But I see no other way if we implement LAST_DAY / FIRST_DAY OF WEEK. |
Commented by: @livius2 Good functions - but do you really think that default should be e.g. month? and if you consider already to add functions please look here :) |
Modified by: @asfernandesassignee: Adriano dos Santos Fernandes [ asfernandes ] |
Modified by: @asfernandesdescription: Firebird lacks very commonly used functions to manage dates. They can be added as UDF or PSQL functions, but since they're very common and need to be registered in every database it would be good to have them as bultin functions. I suggest these two functions: LAST_DAY( <date or timestamp> [ OF { MONTH | YEAR } ) If "OF ..." clause is omitted, it assumes OF MONTH. LAST_DAY(date '2017-09-15') -- 2017-09-30 FIRST_DAY(date '2017-09-15') -- 2017-09-01 => Firebird lacks very commonly used functions to manage dates. They can be added as UDF or PSQL functions, but since they're very common and need to be registered in every database it would be good to have them as bultin functions. I suggest these two functions: FIRST_DAY( OF { MONTH | YEAR | WEEK } FROM <date or timestamp> ) FIRST_DAY(of month from date '2017-09-15') -- 2017-09-01 LAST_DAY(of month from date '2017-09-15') -- 2017-09-30 First day of week is Sunday and last is Saturday. summary: Add builtin functions LAST_DAY and FIRST_DAY => Add builtin functions FIRST_DAY and LAST_DAY |
Modified by: @asfernandesstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 4.0 Beta 1 [ 10750 ] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Done successfully |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @asfernandes
Votes: 5
Firebird lacks very commonly used functions to manage dates. They can be added as UDF or PSQL functions, but since they're very common and need to be registered in every database it would be good to have them as bultin functions.
I suggest these two functions:
FIRST_DAY( OF { MONTH | YEAR | WEEK } FROM <date or timestamp> )
LAST_DAY( OF { MONTH | YEAR | WEEK } FROM <date or timestamp> )
FIRST_DAY(of month from date '2017-09-15') -- 2017-09-01
FIRST_DAY(of year from date '2017-09-15') -- 2017-01-01
FIRST_DAY(of week from timestamp '2017-11-01 12:13:14.5678') -- 2017-10-29 12:13:14.5678
LAST_DAY(of month from date '2017-09-15') -- 2017-09-30
LAST_DAY(of year from date '2017-09-15') -- 2017-12-31
LAST_DAY(of week from timestamp '2017-11-01 12:13:14.5678') -- 2017-11-04 12:13:14.5678
First day of week is Sunday and last is Saturday.
Commits: a2556be
The text was updated successfully, but these errors were encountered: