开发者

How to query on a column of datatype long storing datetime values?

I am working on a table which has a column called ccDate of type long which stores the date values in long format - for example 20021218. Actually it is a datetime value for 2002-12-18 (yyyy-MM-DD). Now i want to query records from this table comparing this datetime values. for example get all records where ccDate < todays's date. How can i do this ? (note : i am working on SQLServer). I am looking for a datab开发者_C百科ase function which can automatically convert these long values to date & compare while querying.


Well assuming that your actual datatype in SQL Server is an integer then something like this will work:

select *
From myTable
Where Cast(Cast(ccDate as varchar(10)) as datetime) < getdate()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜