Solved

SQL Dates

Posted on 2011-03-18
3
205 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with query 3 26
get row value in vb.net 4 14
Help with exporting to excel 4 28
Where does the SQL and Design Columns Hide when converting a Select Query To an Update? 19 49
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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