We help IT Professionals succeed at work.

Conversion of numbers to dates

183 Views
Last Modified: 2013-11-05
This query is meant to retrieve a count of the no. of stocks that have prices in the last 8 days.

select E.exchangename,PH.marketdate,
            count(*) as PriceToday
            from exchange as E left outer join pricehistory as PH
            on E.dsexchangecode=PH.dsexchangecode
            where PH.marketdate > (select CONVERT(nvarchar(30), GETDATE(), 112)-8)
            group by E.exchangename,PH.marketdate


The problem is that the dates are stored in format yyyymmdd, so it's doing arithmetic calcualations not date calculations.  How do I convert it to dates?
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks.

Author

Commented:
and for the speed of the response.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.