Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.


How I get the first and the last day of current month?

asked 17 May '22, 07:55

robotgestus's gravatar image

accept rate: 0%

Do you want to get these as dates? Such as:

select ymd(year(current date), month(current date), 1) as FirstDayOfCurrentMonat,
   cast(dateadd(dd, -1, dateadd(mm, 1, FirstDayOfCurrentMonat)) as date) as LastDayOfCurrentMonth
permanent link

answered 17 May '22, 08:02

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%


I need to put these information like that:

Select * from Table where date between firstdayofcurrentmonth and lastdayofcurrentmonth

(17 May '22, 08:08) robotgestus
Replies hidden

For those conditions, I often use the dateformat function:

select * from MyTable
where dateformat(MyDate, 'yyyy/mm') = dateformat(current date, 'yyyy/mm')
(17 May '22, 09:03) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 May '22, 07:55

question was seen: 1,174 times

last updated: 17 May '22, 09:03