Friday, February 24, 2012

dates

Hello Everyone,
I am working on a database table that was imported from an excel spreadsheet
where the date column value is stored as follow(s)
yyyymmdd this seems to be stored as a numeric value and not as a date value.
So I am trying to write a query on this table where I want to break the data
down by months or by w number. However, I am running into a few problems
with this field because of the way the value is stored as a number and not
necessary as a date field. I was wondering if any one had any ideas on how
to query this field.
J. D.Try the expression: CAST( CAST( dt AS VARCHAR ) AS DATETIME )
Anith|||If all the values in this column are 8-digit integers that would be valid
dates in yyyymmdd format, you should be able to refer to
CAST(CAST(yourColumn as char(8)) as datetime)
and then use any date functions you need.
Steve Kass
Drew University
JD wrote:

>Hello Everyone,
>I am working on a database table that was imported from an excel spreadshee
t
>where the date column value is stored as follow(s)
>yyyymmdd this seems to be stored as a numeric value and not as a date value
.
>So I am trying to write a query on this table where I want to break the dat
a
>down by months or by w number. However, I am running into a few problems
>with this field because of the way the value is stored as a number and not
>necessary as a date field. I was wondering if any one had any ideas on how
>to query this field.
>
>

No comments:

Post a Comment