Azure function - Powershell Date.AddDays not working
Madhu Rao
120
Reputation points
Hi,
I have an Azure function that uses a date span to run a query. I am using the existing date and a (-ve) numeric value.
The below script works on my laptop.
$cldopsemailqrystrtdays = -7 # Set this to how many days back you want to go
$endtime = (Get-Date).Date # Midnight today
$starttime = $endtime.AddDays($cldopsemailqrystrtdays)
Write-Output "Start Time: $starttime"
Write-Output "End Time: $endtime"
I am passing an env: variable in Azure Function to pass on a numerical value that would be the start date of my query. The Azure function fails to recognise the start date.
$cldopsemailqrystrtdays=$env:cldopsemailqrystrtdays
$endtime = (Get-Date).Date
$starttime = ($endtime).AddDays($cldopsemailqrystrtdays)
$starttimemsg = $starttime
$endtimemsg = $endtime
Write-Host "$starttime - $endtime"
Thanks in advance.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,867 questions
Sign in to answer