方法一: SELECT TRUNC(months_between(sysdate, birth)/12) AS age from mytable 方法二: select TRUNC((to_char(sysdate, 'yyyyMMdd') - to_char(birth, 'yyyyMMdd')) / 10000) as age from mytable 注:sysdate 为系统日期时间,birth 为表中出生日期字段 作者:itmyhome
本例中用的是easyUI的datebox $('#cal_birthday').datebox({ onSelect: function(date){ //根据选则的日期计算年龄 //alert(date.getFullYear()+":"+(date.getMonth()+1)+":"+date.getDate()); // 2017:6:12 var years = 0; var diff = 0; d = new Date(); if(date.getFull
首先建立一个表如下: ======================= BirthDay datetime not null Age 通过公式计算得出 ======================= 以上是表的两个字段,通过BirthDay字段的数据自动生成Age字段 Age字段的公式如下: (case when (datediff(year,[BirthDay],getdate()) <> 0) then (ltrim(datediff(year,[BirthDay],getdate()))
<script type="text/javascript"> //jquery页面加载完成后,根据后端的出生日期,计算年龄 $(function () { // 获得今天的时间 var date = new Date(); var birthday = '${userDetail.birthday}'; // alert(birthday); var startDate = new Date(birthday); var newDate = date.getTime()
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Created by qing on 2017/3/28. */ public class AgeUtils { // 根据年月日计算年龄,birthTimeString:"1994-11-14" public static int getAgeFromBirthTime(String birthTimeS
SELECT FLOOR(MONTHS_BETWEEN(SYSDATE,birthday)/12,1) FROM ltteacherinfo where name='朱雪东111'这个报错ORA 00909 :invalid number of arguments这个是怎么错了,计算年龄该怎么算,年龄要整数 --计算员工年龄SELECT FLOOR(MONTHS_BETWEEN(SYSDATE,birthdate)/12) FROM ps_personal_data