Solved

TSQL Syntax

Posted on 2011-03-15
3
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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