Skip to main content

How can we write a data quality rule to check if given date in attribute falls on Sunday or not. If it falls on Sunday, it should pass else it should fail.

Hi ​@karangalepranav

 

You can achieve this using the toString() function with a date formatting parameter. Refer to the Java SimpleDateFormat documentation for more details:
🔗 https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

For example:

  • toString(now(),'u') will return the numeric day of the week (1 = Monday, ..., 7 = Sunday).

  • toString(now(),'E') will return the textual representation (e.g., Mon, Tue, ..., Sun).

To apply this in a data quality rule, simply replace now() with your datetime attribute.
Make sure to validate that your Java environment uses ISO-8601 for weekday numbering, where Sunday is 7. In some regional settings (e.g., US), Sunday might be returned as 1, so a quick test or confirmation of your environment is recommended.

 

Hope this helps!


This helped. Thanks Much


Reply