首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

关于年龄的计算~小弟我是初学者,请大哥们帮帮小弟我!

2012-03-21 
关于年龄的计算~~~~~~~~~我是菜鸟,请大哥们帮帮我!!!在Compute Expression里怎么写表达式,实现小于2岁的显

关于年龄的计算~~~~~~~~~我是菜鸟,请大哥们帮帮我!!!
在Compute Expression里怎么写表达式,实现小于2岁的显示年龄是几个月????
year(today()) - year(date( csny )) 这个是我现在写的~~~

[解决办法]
直接用数据窗口的数据源来实现比较简单,参照下面的例子:

SQL code
declare @t table(a int, b datetime)insert into @tselect 1, '2001-11-01' union allselect 2, '2003-01-21' union allselect 3, '2004-09-12' union allselect 4, '2009-04-01' union allselect 5, '2010-12-14' union allselect 6, '2011-01-12' select     a,     case sign(DATEDIFF(month, b, getdate()) - 24)     when -1 then cast(DATEDIFF(month, b, getdate()) as varchar(4)) + '月'    else cast(DATEDIFF(year, b, getdate()) as varchar(4)) + '岁' end as '年纪'from @t/*结果(所影响的行数为 6 行)a           年纪     ----------- ------ 1           10岁2           8岁3           7岁4           23月5           3月6           2月(所影响的行数为 6 行)*/ 

热点排行