ramz123
ramz123

Reputation: 199

Last Day of Month in Optic Query

Is there any function available in Optic API to identify last day of a month?

I have requirement to identify a date whether its last day of a month or not.

Upvotes: 2

Views: 53

Answers (1)

John Snelson
John Snelson

Reputation: 958

I suggest adding one day to the date/dateTime, and then seeing if the month has changed using sql.month(), ie:

op.fromView('main', 'expenses')
  .bindAs('nextDay', op.sql.timestampadd('SQL_TSI_DAY', 1, op.col("submitted")))
  .where(op.ne(op.sql.month(op.col("submitted")),op.sql.month(op.col("nextDay")))
  .result();

Upvotes: 2

Related Questions