SQL Server函数之数学函数与时间函数


  本文标签:SQL Server函数

  以下的文章主要向大家讲述的是SQL Server函数之数学函数,以及对SQL Server函数之时间函数的描述,以下就是具体方案的描述,希望在你今后的学习中会有所帮助,以下就是文章的详细内容介绍,望大家借鉴  。

  select sin(23.45),atan(1.234),rand(),PI(),sign(-2.34) --其中rand是获得一个随机数

  SQL Server函数之配置函数

  

SELECT @@VERSION --获取当前数据库版本

  

  SELECT @@LANGUAGE --当前语言

  

  SQL Server函数之时间函数

  

  select getdate() as wawa_getdate --当前时间

  

  select getutcdate() as wawa_getutcdate --获取utc时间

  

  select day(getdate()) as wawa_day --取出天

  

  select month(getdate()) as wawa_month --取出月

  

  select year(getdate()) as wawa_year --取出年

  

  select dateadd(d,3,getdate()) as wawa_dateadd --加三天,注意d表示天,m表示月,yy表示年,下面一样

  

  select datediff(d,2004-07-01,2004-07-15) as wawa_datediff --计算两个时间的差

  

  select datename(d,2004-07-15) as wawa_datename --取出时间的某一部分

  

  select datepart(d,getdate()) as wawa_datepart --取出时间的某一部分,和上面的那个差不多

  

  以上的相关内容就是对SQL Server函数之数学函数配置函数以及时间函数的介绍,望你能有所收获  。