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.

Hello,

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

asked 17 May '22, 07:55

robotgestus's gravatar image

robotgestus
15113
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
40.2k361550822
accept rate: 34%

Almost

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
4

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×25

question asked: 17 May '22, 07:55

question was seen: 1,089 times

last updated: 17 May '22, 09:03