Oracle: 
 select to_char(sysdate, 'yyyy') - to_char(t.hiredate, 'yyyy') as age
 from emp t
emp是scott用户内置的表结构,其中hiredate是受雇时间,在这里把它当出生日期测试,其中sysdate是Oracle的系统时间,to_char中第二个参数则是所需要的转换格式。

mysql:
日期函数为:

1.当前日期函数:
 curdate()
如从mysql中提取当前系统日期:
select curdate()

2.当前日期函数:
 curtime()
如mysql中提取当前系统时间:
 select curtime()

3.当前日期时间函数:
 now()
如mysql中提取当前系统时间:
 select now()

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-09
  • 2021-07-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2021-08-27
  • 2021-11-12
  • 2021-07-14
  • 2021-11-17
相关资源
相似解决方案