Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 That’s Not a Date-Time Datatype, Is It? Renee Teatro Information Builders Information Builders Summit 2006 User Conference April 2006.

Similar presentations


Presentation on theme: "1 That’s Not a Date-Time Datatype, Is It? Renee Teatro Information Builders Information Builders Summit 2006 User Conference April 2006."— Presentation transcript:

1 1 That’s Not a Date-Time Datatype, Is It? Renee Teatro Information Builders Information Builders Summit 2006 User Conference April 2006

2 2  Author: Renee Teatro  Company: Information Builders  Presentation Title: That’s Not a Date-Time Datatype,Is It?  Presentation Abstract: Discover all you ever wanted to know about the new Date-Time datatype and the available subroutines for manipulating it. Presentation Information

3 3  Date-Time Datatype Overview  Date-Time Subroutines Overview  Techniques and Examples  Retrieval of System Date and Time  Difference in HH:MM:SS between Date-Time fields  Displaying BOTLOG START_STAMP and END_STAMP values as proper Date-Time fields That’s Not a Date-Time Datatype, Is It? Agenda

4 4 Date-Time Datatype Overview 4 Copyright © 2004 Information Builders, Inc.

5 5 That’s Not a Date-Time Datatype, Is It? USAGE=Hnn  Numeric date-time value without date-time display options  Appropriate for FORMAT ALPHA or transaction files  “nn” – length from 1 to 20  8 characters for the date  YYYYMMDD  9 characters for the time up to milliseconds  HHMMSSsss  12 characters for the time up to microseconds  HHMMSSsssmmm  No spaces, decimal points, or separator characters  Time must use the 24-hour system  => 1999/12/31 10:57: PM

6 6 That’s Not a Date-Time Datatype, Is It? USAGE=Htimefmt1

7 7 That’s Not a Date-Time Datatype, Is It? USAGE=Hdatefmt [separator] [timefmt2]

8 8  Supported datefmt combinations  Year-first: Y, YY, YM, YYM, YMD, YYMD  Month-first: M, MD, MY, MYY, MDY, MDYY  Day-first: D, DM, DMY, DMYY  Default separator for datefmt components: Slash (/)  Period (.)  Hyphen (-)  Blank (B)  None (N)  timefmt2 support at most two characters  One character to represent all time components displayed  Optional character to AM/PM option

9 9 That’s Not a Date-Time Datatype, Is It? USAGE=Hdatefmt [separator] [timefmt2]

10 10 That’s Not a Date-Time Datatype, Is It? ACTUAL Formats  ACTUAL=H8, H10, or H12  Binary HOLD or SAVB format files  ACTUAL=Ann  Alphanumeric HOLD or SAVE format files  USAGE=Hnn  Relational – SQL engine SET DATETIME ON/OFF ***  Oracle  RDBMS Data type of DATE: ACTUAL=HYYMDS  DB2 and SQL/DS  RDBMS Data type of DATE: ACTUAL=DATE  RDBMS Data type of TIME: ACTUAL=HHIS  RDBMS Data type of TIMESTAMP: ACTUAL=HYYMDm

11 11 That’s Not a Date-Time Datatype, Is It? Examples FILENAME=EMPINFO,SUFFIX=SQLDS,$ SEGNAME=EMPINFO,SEGTYPE=S0,$ FIELD=EMP_ID,ALIAS=EID,USAGE=A9,ACTUAL=A9,$ FIELD=LAST_NAME,ALIAS=LN,USAGE=A15,ACTUAL=A15,$ FIELD=FIRST_NAME,ALIAS=FN,USAGE=A10,ACTUAL=A10,$ FIELD=HIRE_DATE,ALIAS=HDT,USAGE=YMD,ACTUAL=DATE,$ FIELD=HIRE_DATE_TIME,ALIAS=HDTT,USAGE=HYYMDm,ACTUAL=HYYMDm,$ FIELD=HIRE_TIME,ALIAS=HT,USAGE=HHIS,ACTUAL=HHIS,$ FILE=DATETIME, SUFFIX=FOC,$ SEGNAME=DATETIME, SEGTYPE=S1,$ FIELD=ID, ID, USAGE=I2,$ FIELD=DT1, DT1, USAGE=HYYMDS, MISSING=ON,$ FILE=DTCOM, SUFFIX=COM,$ SEGNAME=DTCOM, SEGTYPE=S0,$ FIELD=ID, ID, USAGE=I2,ACTUAL=A2,$ FIELD=DT1, DT1, USAGE=HYYMDS,ACTUAL=A17,$ $FIELD=DT1, DT1, USAGE=HYYMDs,ACTUAL=A17,$ $FIELD=DT1, DT1, USAGE=HMTdYYSA,ACTUAL=A28,$ * * * TOP OF FILE * * * 01, :57:25,$ 02, :05:35,$ * * * END OF FILE * * *

12 12 Date-Time Subroutines Overview 12 Copyright © 2004 Information Builders, Inc.

13 13 That’s Not a Date-Time Datatype, Is It? HGETC  Return the current date and time in date-time format HGETC({8|10},'Hformat') DEFINE FILE CAR CURRENT_DATE/YYMD WITH COUNTRY=&YYMD; CURRENT_DATE2/YY-M-D WITH COUNTRY=&YYMD; CURRENT_DATE3/HYYMD= HGETC(8,'HYYMD'); CURRENT_DATE4/HYYMD-= HGETC(8,'HYYMD-'); CURRENT_DATE5/HYYMD.= HGETC(8,'HYYMD.'); CURRENT_DATE6/HYYMDB= HGETC(8,'HYYMDB'); CURRENT_DATE7/HYYMDN= HGETC(8,'HYYMDN'); CURRENT_DATE8/HMTDYY= HGETC(8,'HMTDYY'); CURRENT_DATE9/HMTDkYY= HGETC(8,'HMTDkYY'); CURRENT_DATE10/HMtDkYY= HGETC(8,'HMtDkYY'); CURRENT_TIME/A8 ='&TOD'; CURRENT_TIME1/A8 =HHMMSS('A8'); CURRENT_TIME2/HHISA= HGETC(8,'HHISA'); CURRENT_TIME3/HHISa= HGETC(8,'HHISa'); CUR_DATE_TIME/HYYMDI=HGETC(8,'HYYMDI'); CUR_DATE_TIME2/HYYMDS=HGETC(8,'HYYMDS'); CUR_DATE_TIME3/HYYMDsA=HGETC(8,'HYYMDsA'); CUR_DATE_TIME4/HYYMDma=HGETC(10,'HYYMDma');

14 14 That’s Not a Date-Time Datatype, Is It? HGETC This is the DATE via the YYMD VARIABLE: 2004/05/11 This is the DATE via the YYMD VARIABLE using - SEPARATOR: This is the HGETC DATE via a DEFINE: 2004/05/11 This is the HGETC DATE via a DEFINE: This is the HGETC DATE via a DEFINE: This is the HGETC DATE via a DEFINE: This is the HGETC DATE via a DEFINE: May This is the HGETC DATE via a DEFINE: May 11, 2004 This is the TOD TIME using the VARIABLE directly: This is the TOD TIME using the VARIABLE via a DEFINE: This is the HHMMSS TIME via a DEFINE: This is the HGETC TIME via a DEFINE with UPCASE AM/PM: 11:25:32PM This is the HGETC TIME via a DEFINE with lowcase am/pm: 11:25:32pm This is the HGETC DATE-TIME up to MINUTE COMPONENT: 2004/05/11 23:25 This is the HGETC DATE-TIME up to SECOND COMPONENT: 2004/05/11 23:25:32 This is the HGETC DATE-TIME up to MILLISECOND/UPCASE AM/PM: 2004/05/11 11:25:32.000PM This is the HGETC DATE-TIME up to MICROSECOND/lowcase am/pm: 2004/05/11 11:25: pm

15 15 That’s Not a Date-Time Datatype, Is It? HINPUT and HDIFF  Convert an alphanumeric string to a date-time value HINPUT(inputlength,'inputstring',{8|10},'Hfmt') HDIFF(dtfield1,dtfield2,'component','Dformat')  Returns the number of units of a specific date-time component between two date-time values

16 16 That’s Not a Date-Time Datatype, Is It? Date-Time Subroutine Components

17 17 That’s Not a Date-Time Datatype, Is It? HINPUT and HDIFF DEFINE FUNCTION SDIFF/A8 (IDT/A8,ITM/A6,ODT/A8,OTM/A6) ADATE1/A14 = IDT | ITM; ADATE2/A14 = ODT | OTM; HDATE1/HYYMDS = HINPUT(14, ADATE1, 8, 'HYYMDS'); HDATE2/HYYMDS = HINPUT(14, ADATE2, 8, 'HYYMDS'); HDIFF/D12.2 = HDIFF (HDATE2, HDATE1, 'SECOND', 'D12'); HOURS/I2 = INT(HDIFF / 3600); MINS/I2 = (HDIFF - (HOURS * 3600)) / 60; SECS/I2 = HDIFF - (HOURS * 3600) - (MINS * 60); SDIFF/A8 = EDIT(HOURS) | ':' | EDIT(MINS) | ':' | EDIT(SECS); END DEFINE FILE CAR SECDIFF/A8=SDIFF(' ','081003',' ','081005'); END …

18 18 That’s Not a Date-Time Datatype, Is It? HINPUT and HDIFF ODATE OTIME IDATE ITIME SECDIFF 00:00:02 ODATE OTIME IDATE ITIME SECDIFF 00:02:00 ODATE OTIME IDATE ITIME SECDIFF 01:00:00 ODATE OTIME IDATE ITIME SECDIFF 01:02:02

19 19 That’s Not a Date-Time Datatype, Is It? HADD  Increments date-time value by a specified number of units HADD(dtfield,'component',increment,{8 | 10},'Hformat') DEFINE FILE CAR TRANDATE/HYYMDI= HINPUT (12, ' ', 8, 'HYYMDI'); INCDATE/HYYMDI= HADD(TRANDATE, 'MINUTE', 100, 8, 'HYYMDI'); DECDATE/HYYMDI= HADD(TRANDATE, 'MINUTE', -100, 8, 'HYYMDI'); END TABLE FILE CAR PRINT TRANDATE INCDATE DECDATE BY COUNTRY IF COUNTRY EQ 'ENGLAND' END COUNTRY TRANDATE INCDATE DECDATE ENGLAND 2002/02/11 12: /02/11 14: /02/11 10:41

20 20 That’s Not a Date-Time Datatype, Is It? HDTTM  Convert date field to a date-time field with time set to midnight HDTTM(datefield,{8|10},Hformat) DEFINE FILE BOTLOG BOT_START/D14=EDIT(START_STAMP); BOT_END/D14=EDIT(END_STAMP); BASE_DATE/YYMD= ; HBASE_DATE/HYYMDIA=HDTTM(BASE_DATE,8,'HYYMDIA'); BOTLOG_START/HYYMDS= HADD(HBASE_DATE,'MILLISECONDS',BOT_START,8,'HYYMDS'); BOTLOG_END/HYYMDS= HADD(HBASE_DATE,'MILLISECONDS',BOT_END,8,'HYYMDS'); END BOT_START BOT_END BASE_DATE HBASE_DATE ,052,031,303,000 1,052,031,305, /01/ /01/01 12:00AM 1,052,708,103,000 1,052,708,106, /01/ /01/01 12:00AM BOTLOG_START BOTLOG_END /05/04 06:55: /05/04 06:55: /05/12 02:55: /05/12 02:55:06

21 21 That’s Not a Date-Time Datatype, Is It? HNAME  Extracts specified components of a date-time value and converts them to alphanumeric format HNAME(dtfield,'component',Aformat) SET WEEKFIRST=7 SET DATEFORMAT=DMY DEFINE FILE CAR TRANDATE/HYYMDS= HINPUT(19, '01/05/ :31:25', 8, 'HYYMDS'); WEEK_COMPONENT/A2= HNAME(TRANDATE, 'WEEK', 'A2'); DAY_COMPONENT/A2= HNAME(TRANDATE, 'DAY', 'A2'); END COUNTRY TRANDATE WEEK_COMPONENT DAY_COMPONENT ENGLAND 2004/05/01 15:31: SET DATEFORMAT=MDY ENGLAND 2004/01/05 15:31:

22 22 That’s Not a Date-Time Datatype, Is It? HPART  Extracts a component of a date-time value in numeric format HPART(dtfield,'component','Iformat') SET WEEKFIRST=7 SET DATEFORMAT=DMY DEFINE FILE CAR TRANDATE/HYYMDS= HINPUT(19, '01/05/ :31:25', 8, 'HYYMDS'); WEEK_COMPONENT/I2= HPART(TRANDATE, 'WEEK', 'I2'); MONTH_COMPONENT/I2= HPART(TRANDATE, 'MONTH', 'I2'); END COUNTRY TRANDATE WEEK_COMPONENT MONTH_COMPONENT ENGLAND 2004/05/01 15:31: SET DATEFORMAT=MDY ENGLAND 2004/01/05 15:31:25 1 1

23 23 That’s Not a Date-Time Datatype, Is It? HSETPT  Insert numeric value of specified component in date-time field HSETPT(dtfield,'component',value,{8|10},'Hformat') DEFINE FILE CAR TRANDATE/HYYMDm= HINPUT(20, ' ', 10, 'HYYMDm'); SETPT1/HYYMDm= HSETPT(TRANDATE,'DAY',15,10,'HYYMDm'); SETPT2/HYYMDmA= HSETPT(TRANDATE,'MONTH',12,10,'HYYMDmA'); END TRANDATE SETPT /01/05 15:31: /01/15 15:31: SETPT /12/05 3:31: PM

24 24 That’s Not a Date-Time Datatype, Is It? HCNVRT  Converts date-time value to alphanumeric format HCNVRT(dtfield,'(Hfmt)',rlength,'Ann') DEFINE FILE CAR TRANDATE/HYYMDm= HINPUT(20, ' ', 10, 'HYYMDm'); CNVRT1/A26= HCNVRT(TRANDATE,'(HYYMDm)',26,'A26'); CNVRT2/A20= HCNVRT(TRANDATE,'(H20)',20,'A20'); CNVRT3/A18= HCNVRT(TRANDATE,'(HMTdkYY)',18,'A18'); END TRANDATE CNVRT /01/05 15:31: CNVRT2 CNVRT January 5, 2004

25 25 That’s Not a Date-Time Datatype, Is It? HMIDNT  Changes the time portion of a date-time field to midnight HMIDNT(dtfield,{8|10},'Hformat') DEFINE FILE CAR TRANDATE/HYYMDm= HINPUT(20, ' ', 10, 'HYYMDm'); MIDNT1/HYYMDm= HMIDNT(TRANDATE,10,'HYYMDm'); MIDNT2/HYYMDmA= HMIDNT(TRANDATE,10,'HYYMDmA'); END TRANDATE MIDNT /01/05 15:31: /01/05 00:00: MIDNT /01/05 12:00: AM

26 26 That’s Not a Date-Time Datatype, Is It? HDATE  Extract date components from a date-time field and convert them to a date field HDATE(dtfield,'dateformat') DEFINE FILE CAR TRANDATE/HYYMDm= HINPUT(20, ' ', 10, 'HYYMDm'); SMARTDATE/M-D-YY= HDATE(TRANDATE,'M-D-YY'); END COUNTRY TRANDATE SMARTDATE ENGLAND 2004/01/05 15:31:

27 27 That’s Not a Date-Time Datatype, Is It? HTIME  Extract all of the time components from a date-time field and convert them to a number of milliseconds or microseconds in numeric format HTIME({8|10},dtfield,'Dformat') DEFINE FILE CAR TRANDATE/HYYMDm= HINPUT(20, ' ', 10, 'HYYMDm'); MILLISEC/D14= HTIME(8,TRANDATE,'D14'); MICROSEC/D14= HTIME(10,TRANDATE,'D14'); END COUNTRY TRANDATE MILLISEC MICROSEC ENGLAND 2004/01/05 15:31: ,885,123 55,885,123,456

28 28 Copyright © 2004 Information Builders, Inc.


Download ppt "1 That’s Not a Date-Time Datatype, Is It? Renee Teatro Information Builders Information Builders Summit 2006 User Conference April 2006."

Similar presentations


Ads by Google