SQL Query Help - Date Time Query

Posted on 2011-05-02
Last Modified: 2012-05-11

I have a column "ReportTimeStamp" in a table which is "smalldatetime" datatype.

Data inside those columns will be like this, " 2011-05-02 01:01:00 "

I need to write a query where ReportTimeStamp in (5/2/2011) & so on. I am currently unable to do the same.

Example query am using:
select agingbucket, count(*) as 'Mon' from
(select a.ReportTimeStamp, a.Team, a.Manager, a.SR_Owner, a.[Group], a.SR_ID_No, a.SR_Type,
a.Severity, a.Days_Open, b.Agingbucket, b.orderoption from
(select cast(ReportTimeStamp as datetime) as ReportTimeStamp,
Team, Manager, SR_Owner, [Group], SR_ID_No, SR_Type, Severity, Days_Open from backlograw
Where Team in (@Team) and Reporttimestamp in
(SELECT (CAST(MONTH(getdate() -  datepart(dw, getdate()) + 2)
AS varchar(2)) + '/' + CAST(DAY(getdate() -  datepart(dw, getdate()) + 2) AS varchar(2)) + '/' +
CAST(YEAR(getdate() -  datepart(dw, getdate()) + 2) AS varchar(4))) Mon)) a
Inner Join
(select [Difference], AgingBucket, orderoption from FlexAgingBucket) b
on a.Days_Open = b.[Difference]) a
group by agingbucket

Its throwing no result at all. pls help
Question by:davidi1
    LVL 33

    Accepted Solution

    What date range are you looking for?  Plus or minus 2 days from the current date?
    LVL 2

    Author Comment

    nevermind. i got it..,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 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

    14 Experts available now in Live!

    Get 1:1 Help Now