Solved

SQL Dates

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

11 Experts available now in Live!

Get 1:1 Help Now