I am trying to calculate the number of days of the current of month from day 1 until yesterday without the need of changing the count manually. The original SQL as below:
select order_id from orders where date > dateadd(-23 to current_date) and date < 'today'
the desired code is something like
select order_id from orders where date > dateadd(datediff(day,firstdayofthemonth,current_date) to current_date) and date < 'today'
Appreciate any help
Advertisement
Answer
In firebird you could do:
WHERE date >= DATEADD(1 - EXTRACT(DAY FROM CURRENT_DATE) DAY TO CURRENT_DATE) AND date < CURRENT_DATE