August 25, 2009 at 10:41 pm
Hi Folks,
How to get the first ay of any month, Normally we will concatenate '01' TO DATE FUNTION and set 01 as the default first day of the month.bUT FOR EVERY MONTH I SHOULD GET FIRST DAY
EXAMPLE; firstday of the month is 01 with their datename(week day)
August 25, 2009 at 11:17 pm
HI,
TRY THIS
select getdate() + (1 - DAY(getdate()))
select DATENAME(weekday,(getdate() + 1 - DAY(getdate())))
August 26, 2009 at 9:41 am
Here's a link to a blog post by Lynn Pettis that I refer to whenever I need a date routine.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 26, 2009 at 10:19 am
select FirstDayOfMonth = dateadd(mm,datediff(mm,0,getdate()),0)
Results:
FirstDayOfMonth
-----------------------
2009-08-01 00:00:00.000
January 9, 2017 at 1:56 am
select getdate() + ((1 - DAY(getdate()))) If today is 01 then it wont work to pick first day of month..
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply