Solved

SQL Dates

Posted on 2011-03-18
3
196 Views
Last Modified: 2012-05-11
I need to run a report that gets the current day, then 3 months in advance.

--            AND (TblApptDetails.ApptConfirmedDate
--            BETWEEN @FromDate AND @ToDate)
0
Comment
Question by:aneilg
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35163804
article on how to handle dates in general in sql server: http://www.experts-exchange.com/A_1499.html

now, what is the actual problem on your side?
* calculating the @From and @To ?
* passing the values from vb to sql ?
* something else?

please clarify
0
 
LVL 10

Accepted Solution

by:
Asim Nazir earned 125 total points
ID: 35163836
Something like:
SELECT DATEADD(month, 3, GetDate())

I hope it helps.
Asim
0
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 125 total points
ID: 35165621
Try this:

            AND (TblApptDetails.ApptConfirmedDate
            BETWEEN CAST(GETDATE() AS SMALLDATE) AND CAST(DATEADD(month, 3, GETDATE()) AS SMALLDATE)

Open in new window


The CAST is to remove the time part.

I hope this helps.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

21 Experts available now in Live!

Get 1:1 Help Now