# Date Decrement Days ?

\
This wildcard allows you to generate a new date string by subtracting a specified number of days from today's date. The node takes an input integer, decrements it, and provides a new date.

For instance (today: 2024-01-24): {date.decrement.days.5} -> 2024-01-19

{% hint style="warning" %}
Ensure that the format of the resulting date conforms to the pattern YYYY-MM-DD if it is intended for use in another date-time node.

In Helmut4 version 4.7.x and earlier, the wildcard returned the pattern DD-MM-YYYY, which could not be directly used to update date metadata.
{% endhint %}

<details>

<summary>Convert Date Format from DD-MM-YYYY to YYYY-MM-DD</summary>

Code to convert date with javascript node

```javascript
// Input date string (replace '{stream.variable.newDate}' with your actual date string)
var inputDateString = '{stream.variable.newDate}';

// Function to convert date string from one format to another
function convertDateString(inputDateString) {
    // Import required Java classes
    var SimpleDateFormat = Java.type('java.text.SimpleDateFormat');
    var Date = Java.type('java.util.Date');

    // Define input and output date formats
    var inputFormat = new SimpleDateFormat('dd-MM-yyyy');
    var outputFormat = new SimpleDateFormat('yyyy-MM-dd');

    try {
        // Parse the input date string using the input format
        var date = inputFormat.parse(inputDateString);

        // Format the parsed date using the output format
        var outputDateString = outputFormat.format(date);

        return outputDateString;
    } catch (e) {
        // Handle any parsing or formatting errors
        print('Error occurred during date conversion: ' + e);
        return null; // Return null in case of error
    }
}

// Call the conversion function with the input date string
var outputDateString = convertDateString(inputDateString);

// Output the result (formatted date string) to the caller
outputDateString;

```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/date-and-time-21/date-decrement-days.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
