Reputation: 930
I inherited a report that has the following line of code:
ftb2.gwy_strt_tmsp >cast((current_date -extract(day from current_date)) as timestamp(6))))
This report runs on the 1st day of the month. I don"t understand the date criteria being used. Does this code mean that it subtracts the day of the month from the current date to find a date? Any explanation as to what this line of code is doing would be greatly appreciated. Thanks for the help.......
Upvotes: 1
Views: 53
Reputation: 1269633
The expression extract(day from current_date)
gets the current day of the month.
Subtracting this from the current date produces the last day of the previous month.
The comparison >
says "any date matches that is after the last day of the previous month". Assuming gwy_strt_tmsp
has no time component, and no timestamps are in the future, then this is a shorthand for "get me records in the current month".
If gwy_start_tmsp
has a time component, then it would also get records from the last day of the previous month.
Upvotes: 3