Hello,

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

asked 17 May, 07:55

robotgestus's gravatar image

robotgestus
1513
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, 08:02

Volker%20Barth's gravatar image

Volker Barth
38.9k351532800
accept rate: 34%

Almost

I need to put these information like that:

Select * from Table where date between firstdayofcurrentmonth and lastdayofcurrentmonth

(17 May, 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, 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:

×23

question asked: 17 May, 07:55

question was seen: 256 times

last updated: 17 May, 09:03