Add time using the DateNowUtc filter

(David Gard) #1

Good afternoon,

I have a scenario whereby I need to pass in a time that is 1 hour in the future to an ARM template. With variable filters, I can pass in the current time -

#{ | NowDateUtc}

However, looking at the docs for the NowDateUtc variable filter, I can’t see any way to add time.

Is this possible?

Thanks,
David

(Ziaul Islam) #3

Hi David,

Thank you for the question.

This is indeed possible. The simplest way would be to use a PowerShell script.
You will need to use GetDate.AddHours() method.

The link below will contain a few examples :

https://devblogs.microsoft.com/scripting/adding-and-subtracting-dates-with-powershell/

I hope this helps you :slight_smile:

Kind regards,
Ziaul

(David Gard) #4

Thanks for the reply, but I’m not sure this is what I’m after. I know how to manipulate dates with PowerShell, but I can’t use PowerShell inside an ARM template.

Thanks,
David

(Ziaul Islam) #6

Hi David,

You’ll need to use the method GetDate.AddHours() in a previous script step. Once you have done this you will need to set an output variable with the result. Now that you have the output variable you can use that in your ARM template.

sorry, I should have explained that a lot better.

I hope this helps, any further questions please feel free to reach out.

Kind regards,
Ziaul

(David Gard) #7

The trouble is, it’s not always convenient to use PowerShell, hence the question.

I have created a suggestion on User Voice to add this feature.

Thanks,
David

1 Like