c*****d 发帖数: 6045 | 1 首先,这种设计就是没事找事。
日期型的就用日期型,容易操作,比如dateadd, + 1 day, trunc, etc
显示给用户的时候只要用to_char(ym1, 'yyyymm')就屏蔽了dd
其次,Oracle没有DATEADD这么个函数
如果现在这个字段是数值型的
where ym1 BETWEEN
TO_NUMBER(TO_CHAR(add_months(dob,12*12),'YYYYMM')) AND
TO_NUMBER(TO_CHAR(add_months(dob, 13*12),'YYYYMM')) |
|
p********a 发帖数: 5352 | 2 The date field (ym1) in the table is numeric like 201401 (year + month). It
is difficult to compare this date with other date fields since it is numeric
What is wrong with the this experision?
where ym1 BETWEEN
TO_NUMBER(TO_CHAR(DATEADD(YY,12,dob),'YYYYMM'),999999) AND
TO_NUMBER(TO_CHAR(DATEADD(YY,13,dob),'YYYYMM'),999999)
What is the best way to make this date between the 12th birthday and 13th
birthday?
Thanks in advance! |
|
tj 发帖数: 957 | 3 or
where ym1 between to_char (dob, 'yyyymm') - 1300 and to_char (dob, 'yyyymm')
- 1200 |
|
n****f 发帖数: 905 | 4 where ym1 BETWEEN
TO_DATE (your_date_1, 'YYYYMM') and TO_DATE (your_date_2, 'YYYYMM')
It
numeric |
|
s**********o 发帖数: 14359 | 5 YYYYMM还是有好处的,比如DW的数据都是这么存的,多数公司只关心MONTH以上的数据
其实就按YYYY*100+MM,当数字算好了 |
|
s**********o 发帖数: 14359 | 6 YYYYMM的存法,只用在DATAWARE HOUSE里,不用在OLTP
價。 |
|
s**********o 发帖数: 14359 | 7 YYYYMM的存法,只用在DATAWARE HOUSE里,不用在OLTP
好像只在ORACLE里见到
價。 |
|
n****f 发帖数: 905 | 8 then how you create these YYYYMM values? |
|
p********a 发帖数: 5352 | 9 我也觉得日期YYYYMM的NUMERIC值很笨。我是用SAS PASS THRU到ORACLE的,头疼死了 |
|
n****f 发帖数: 905 | 10 you can convert them to date and insert into the date field:
TO_DATE( 'Your_YYYY' || 'Your_MM', 'YYYYMM') |
|