Solved

SQL Dates

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

789 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