[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

SQL Query Help - Date Time Query

Team,

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
0
davidi1
Asked:
davidi1
1 Solution
 
knightEknightCommented:
What date range are you looking for?  Plus or minus 2 days from the current date?
0
 
davidi1Author Commented:
nevermind. i got it..,
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now