Implementing DATEDIFF Function In Data Factory / Synapse Via Pipeline Expressions

Harsh Bakshi
3 min readSep 27, 2023

--

Problem Statement

In Azure Data Factory / Synapse, there are no dedicated functions under pipeline expressions equivalent to DATEDIFF.

So is it possible to reciprocate DATEDIFF in ADF / Synapse without the use of Dataflow?

What is DATEDIFF() Function?

The DATEDIFF() function returns the difference between two dates.

Syntax

DATEDIFF(interval, date1, date2)

Date1 Date2 Interval Output 2015/08/25 07:00 2017/08/25 12:45 Year 2 2015/08/25 07:00 2017/08/25 12:45 Quarter 8 2015/08/25 07:00 2017/08/25 12:45 Month 24 2015/08/25 07:00 2017/08/25 12:45 Week 104 2015/08/25 07:00 2017/08/25 12:45 Day 731 2015/08/25 07:00 2017/08/25 12:45 Hour 17549 2015/08/25 07:00 2017/08/25 12:45 Minute 1052985 2015/08/25 07:00 2017/08/25 12:45 Second 63179100 2015/08/25 07:00 2017/08/25 12:45 MilliSecond 63179100000

Prerequisites

  • Azure Data Factory / Synapse
Azure Data Factory
  • Variables
sheet
  • where Week, Day, Hour, Minute, Second, and Millisecond are variables with values for conversion from Tick to the named entity.

How to use Interval values?

Interval values, also known as value ranges, are a way to express uncertainty or variability in data. They represent a range of possible values rather than a single point, making them valuable in situations where precision is limited. Interval values, also known as value ranges, are a way to express uncertainty or variability in data. They represent a range of possible values rather than a single point, making them valuable in situations where precision is limited.

Different CASE or Different Value

“Different CASE or different Value” is crucial for implementing conditional logic. This idea revolves around making decisions based on varying conditions or values. Different cases often lead to different outcomes or actions in a program. For instance, in a switch statement, different cases represent distinct scenarios, and the code within each case block executes when the corresponding condition or value matches. Whether it’s branching logic in decision-making processes, handling user inputs, or managing various data states, the ability to handle different cases or values elegantly is fundamental to writing efficient and functional code.

  • year
CASE or different Value
  • Random values like ‘yyyy’
Random value

Know more about our company at Skrots. Know more about our services at Skrots Services. Also, check out all other blogs at Blog at Skrots.

Thank you!

Thanks, Harsh
Founder | CEO — Skrots

Learn more about our blog at Blog at Skrots. Checkout our list of services on Skrots. Give a look at our website design at Skrots . Checkout our LinkedIn Page at LinkedIn.com. Check out our original post at https://blog.skrots.com/implementing-datediff-function-in-data-factory-synapse-via-pipeline-expressions/?feed_id=2662&_unique_id=6514021539b02.

--

--

No responses yet