cancel
Showing results for 
Search instead for 
Did you mean: 

get the first and the last day of current month

0 Kudos
1,656

Hello,

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

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

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
0 Kudos

Almost

I need to put these information like that:

Select * from Table where date between firstdayofcurrentmonth and lastdayofcurrentmonth

VolkerBarth
Contributor

For those conditions, I often use the dateformat function:

select * from MyTable
where dateformat(MyDate, 'yyyy/mm') = dateformat(current date, 'yyyy/mm')

Answers (0)