数据库中查询时间精确到秒 方法是什么?
------解决方案--------------------
- SQL code
1> select2> DATEPART ( year , getdate() ) as year,3> DATEPART ( month , getdate() ) as month,4> DATEPART ( day , getdate() ) as day,5> DATEPART ( hour , getdate() ) as hour,6> DATEPART ( minute , getdate() ) as minute,7> DATEPART ( second , getdate() ) as second,8> DATEPART ( millisecond , getdate() ) as millisecond9>10> goyear |month |day |hour |minute |second |millisecond-----------|-----------|-----------|-----------|-----------|-----------|----------- 2010| 9| 24| 17| 30| 56|647(1 rows affected)1>
------解决方案--------------------
1> select
2> DATEPART ( year , getdate() ) as year,
3> DATEPART ( month , getdate() ) as month,
4> DATEPART ( day , getdate() ) as day,
5> DATEPART ( hour , getdate() ) as hour,
6> DATEPART ( minute , getdate() ) as minute,
7> DATEPART ( second , getdate() ) as second,
8> DATEPART ( millisecond , getdate() ) as millisecond