select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual
字符串转日期
select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual
select date_format(now(),'%Y-%m-%d')
select str_to_date('2016-01-02','%Y-%m-%d %H')
select unix_timestamp('2016-01-02')
select from_unixtime(1451997924,'%Y-%d')
select unix_timestamp(now())
select from_unixtime(1451997924)
依次取出字段的年月日时间分秒就组成了串YYYY+MM+DD+HH+MS+SS
你有了这个串,就可以随意 *** 作了,不同数据库中,获取这些时间戳的函数不一样,以Sybase为例,在Sybase中,该函数为:
datepart(日期部分,日期)
取指定时间的某一个部分,年月天时分秒.
使用方法如下:
select datepart(yy,getdate()) --year
select datepart(mm,getdate()) --month
select datepart(dd,getdate()) --day
select datepart(hh,getdate()) --hour
select datepart(mi,getdate()) --min
select datepart(ss,getdate()) --sec
有问题Hi我.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)