SSIS get time expression

Source: Internet
Author: User
Tags ssis

SSIS expression

1. Calculate the number of times a substring appears in a string
Number of occurrences of "." In the Liang. Liang string

Set the string variable to v_str

SQL code
        Len(@[User: v_str])-(Len(Replace(@[User: v_str],".",""))/Len("."))

 

2. If the current date is Saturday, the string "break" is returned; otherwise, the string "work" is returned.

SQL code
      datepart   (" weekday ",   getdate   ()  =    7    ||    datepart   (" weekday ",   getdate   ()  =    1  ? "Break": "work"  

3. Return date format
Yyyy-mm-dd hh: mm: SS

SQL code
    (Dt_wstr,  4  )  Year  (  Getdate  ())  +  "  -  "  +     Right ("  00  "  +  (Dt_wstr,  2  )  Month  (  Getdate  ()),  2  )  +  "  -  " +     Right  ("  00  "  +  (Dt_wstr,  2  )  Day  (  Getdate  ()),  2  )  + ""  +     Right  ("  00  "  +  (Dt_wstr,  2  )  Datepart  ("Hour ",  Getdate  ()),  2  ) +  ":"  +     Right  ("  00  "  +  (Dt_wstr,  2  )  Datepart  ("Minute ",  Getdate  ()),  2 )  +  ":"  +     Right  ("  00  "  +  (Dt_wstr,  2  )  Datepart  ("Second ",  Getdate  ()), 2  ) 

Mm/DD/YYYY

SQL code
    Right  ("  00  "  +  (Dt_wstr,  2  )  Month  (  Getdate  ()), 2  )  +  "  /  "  +     Right  ("  00  "  +  (Dt_wstr,  2  )  Day  ( Getdate  ()),  2  )  +  "  /  "  +  (Dt_wstr,  4  )  Year  (  Getdate  ()) 

4. in SSIs expressions, up to 4000 characters are returned in. (dt_wstr, <length>) and (dt_str, <length>, <code_page>.
Replicate ("X", 4000) successful
Replicate ("X", 4001) failed

5. In fact, SSIS expressions are almost the same as SQL Server expressions. Therefore, if you are familiar with SQL Server, SSIS expressions are easy to use.

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.