October 3, 2001 at 12:42 pm
Do you have any idea how to find the last day of the previous month?
The select I have below works, however I am more than sure that there shoud be another less complex way to do it.
select datediff(day, convert(varchar(4),
year(getdate())) + '/' +
convert(varchar(25),(month(getdate()) -1)) + '/' +
convert(varchar(25),day(getdate())) ,
convert(varchar(4), year(getdate())) + '/' +
convert(varchar(25),month(getdate()))+ '/' +
convert(varchar(25),day(getdate())))
Thank you,
Liya
October 8, 2001 at 3:26 pm
Try this:
print Dateadd(day, -1 * (day(getdate())), getdate())
Unless there's a system proc that does it, I think this is about as clean as you'll get.
October 8, 2001 at 4:08 pm
Pretty good Jason - though I think if you want a rock solid EOM function, you'd want to eliminate the time portion, easily done though.
Andy
October 9, 2001 at 8:17 am
quote:
Try this:print Dateadd(day, -1 * (day(getdate())), getdate())
Unless there's a system proc that does it, I think this is about as clean as you'll get.
Jason,
Wow!!! Well done, great job! Thank you very much.
Liya
October 16, 2001 at 6:46 am
quote:
Do you have any idea how to find the last day of the previous month?The select I have below works, however I am more than sure that there shoud be another less complex way to do it.
select datediff(day, convert(varchar(4),
year(getdate())) + '/' +
convert(varchar(25),(month(getdate()) -1)) + '/' +
convert(varchar(25),day(getdate())) ,
convert(varchar(4), year(getdate())) + '/' +
convert(varchar(25),month(getdate()))+ '/' +
convert(varchar(25),day(getdate())))
Thank you,
Liya
Yours SQL Friend
October 16, 2001 at 6:47 am
Just do this SQL-Statement.
Select Convert(DateTime,Convert(Varchar(4),DatePart(YYYY, GetDATE()))
+'/'+Convert(Varchar(2),DatePart(mm,GetDate()))+'/'+'01') - 1
Yours SQL Friend
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply