Skip to main content
Question

DQ rule on Date Validation

  • July 15, 2025
  • 2 replies
  • 36 views

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.

2 replies

konstantinos.patikas
Ataccamer
Forum|alt.badge.img+3

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!


  • Author
  • Data Voyager
  • 1 reply
  • July 23, 2025

This helped. Thanks Much