Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Conversion of numbers to dates

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?
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlHal2

ASKER

Thanks.
Avatar of AlHal2

ASKER

and for the speed of the response.