Date without the time

前端 未结 2 493
渐次进展
渐次进展 2020-12-22 01:58

I\'m working with SQL Server 2005.

I have a column called purchase_time of type datetime. How do I select this column with the time part - just the date.

Tha

2条回答
  •  一向
    一向 (楼主)
    2020-12-22 02:28

    In SQL Server 2008 you can use the newly added date type:

    select convert(date, purchase_time) from TableName
    

    Update:

    In versions prior to SQL 2008, I used the following solution for this problem:

    select convert(datetime, convert(int, convert(float, purchase_time)))
    from TableName
    

提交回复
热议问题