1.在查询语句中使用字符串函数:select sh.编号,sh.姓名,sh.出生日期,mid(sh.出生日期,1,7) AS 出生年月 from shujubiao as sh
说明MID函数截取字符串位数,获取字符串中一部分信息MID(string,start,length)
2.在查询中使用日期函数:select sh.编号,sh.姓名,sh.出生日期,DateDiff('yyyy',sh.出生日期,DATE()) AS 年龄 from shujubiao as sh
说明DATEDIFF函数计算当前日期与指定日期的时间差DATEDIFF(datepart,startdate,enddate)
datepart:year,quarter,monthn,dayofyear,day,week,hour,minute,second,millisecond
3.在查询时为表中的空字段添加默认信息:select 编号,姓名,工资,(ISNULL(加班天数,0)) as 加班天数,(ISNULL(加班工资,0)) as 加班工资 from isnull where 编号='"+m_Edit+"'
说明ISNULL指定替换值替换NULL,ISNULL(check_expression,replacement_value)