|
-
Mar 13th, 2013, 10:08 AM
#1
Thread Starter
Frenzied Member
MSSQL - from today upto end of the month
Hi,
I currently use the following code to select records of the current month and year.
Code:
SELECT * FROM x where DATEADD(mm,DATEDIFF(mm,0,dateofservice),0)=DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
But now I would only like to show records of the current month but only for current day and future days of the month.
(ex. assuming tday is 03/13/2013
TO SHOW
03/13/2013 ... 03/31/2013
NOT TO SHOW
03/01/2013 ... 03/12/2013
I was wondering if you could give me some tips on how to make this work.
Thanks
-
Mar 14th, 2013, 09:31 AM
#2
Re: MSSQL - from today upto end of the month
Read this article
[edit]
SELECT DATEADD(DD,-DAY(DATEADD(m,1,GETDATE())),DATEADD(m,1,GETDATE()))
will give you the last day of the month.
[/edit]
Last edited by abhijit; Mar 14th, 2013 at 09:47 AM.
Reason: query testing
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|