Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Last 6 months of data based on date feild that is an integer data type

$
0
0

Hi Folks

I have a date column called 'YYYYMM' that is an Integer data type in YYYYMM format (eg. 201309). I want to return records from the last 6 months. 

If the column was in a date format I could use something like 

[YYYYMM] >DATEADD(M, -6, CURRENT_TIMESTAMP)

Therefore I assume I need to do a CONVERSION of INT into a date format with something like

CONVERT (DATE, [YYYYMM]

But I get the message  "Explicit conversion from data type int to date is not allowed"

Can someone suggested a work around?

Many thanks Steve


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>