Solved

TSQL Syntax

Posted on 2011-03-15
3
348 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now