Solved

TSQL Syntax

Posted on 2011-03-15
3
350 Views
Last Modified: 2012-05-11
Dear Experts

I have a table consisting of the following fields:

ref               int
issue           int
startdate     date/time
expdate      date/time

I would like to be able to select issue from the table where the expdate falls within the month after this month.  I understand I will have to use GETDATE to work out the current month but I am not sure on the correct syntax for this.

Can anyone help

Thanks

 
0
Comment
Question by:grantballantyne
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
LeDaouk earned 400 total points
ID: 35137789
SELECT Issue
FROM Table
WHERE DATEDIFF(day, getdate(),expdate)  = 1
0
 
LVL 33

Assisted Solution

by:knightEknight
knightEknight earned 100 total points
ID: 35137848
slight correction:

WHERE datediff( MONTH, getdate(), expdate ) = 1
0
 
LVL 4

Expert Comment

by:LeDaouk
ID: 35137928
yeh sorry month
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now