Kettle date parameter usage

Source: Internet
Author: User

Kettle date parameter usage

When you use the date type parameter to compare the data size, make sure that the passed date type parameter and the comparison type are consistent.

It is common to use date-type parameters in ETL. For example, the SQL statement is as follows:

 
  SELECT b.display_name,a.company_id,date_format(max(first_send_notice_date), ‘%Y-%m’) accMonth,count(*) totalReport,sum(CASE WHEN a.takeoff_time > ‘1980’ THEN 1 ELSE 0 END) removed ,sum(CASE WHEN a.takeoff_time > ‘1980’AND a.takeoff_time < a.first_send_notice_date + interval 1 DAY THEN 1 ELSE 0 END) 1DAY ,sum(CASE WHEN a.takeoff_time >=a.first_send_notice_date + interval 1 DAYAND a.takeoff_time < a.first_send_notice_date + interval 3 DAY THEN 1 ELSE 0 END) 2_3day ,sum(CASE WHEN a.takeoff_time >=a.first_send_notice_date + interval 3 DAYAND a.takeoff_time < a.first_send_notice_date + interval 5 DAY THEN 1 ELSE 0 END) 4_5day ,sum(CASE WHEN a.takeoff_time >=a.first_send_notice_date + interval 5 DAYAND a.takeoff_time < a.first_send_notice_date + interval 7 DAY THEN 1 ELSE 0 END) 6_7day,sum(CASE WHEN a.takeoff_time >=a.first_send_notice_date + interval 7 DAY THEN 1 ELSE 0 END) 7DAY,current_timestamp ETL_DTEFROM FACT_matchedVideo aJOIN DIM_trackingWebsite b ON a.trackingWebsite_id = b.trackingWebsite_idWHERE a.first_send_notice_date >= date_format(‘FIRSTDAYOFLASTMONTH′,‘ANDa.firstsendnoticedate{FIRSTDAYOFCURMONTH}’, ‘%Y-%m-%d’)AND a.count_send_notice> 0AND a.hide_flag = 2AND b.website_type in(‘ugc’,’hybrid’)GROUP BY 1, 2
 

One of the where filter conditions is:

A. first_send_notice_date> = date_format ('$ {FIRSTDAYOFLASTMONTH}', '% Y-% m-% D ')

When the parameter is passed over, the date format of kettle is:

'Yyyy-MM-dd HH: mm: ss' format: '2017/01 00:00:00'

The date format in the database is 'yyyy-MM-dd HH: mm: ss'

If the two are compared, the following error occurs:

select ‘2015/05/01 00:00:00’ > ‘2015-05-02 00:00:00’;+———————————————–+| ‘2015/05/01 00:00:00’ > ‘2015-05-02 00:00:00’ |+———————————————–+| 1 |+———————————————–+

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.