Skip to content

Instantly share code, notes, and snippets.

@schwartzmx
Created February 17, 2016 03:29
Show Gist options
  • Save schwartzmx/14597fba6191d8446305 to your computer and use it in GitHub Desktop.
Save schwartzmx/14597fba6191d8446305 to your computer and use it in GitHub Desktop.
# Quick abstraction test
$d = (Get-Date)
$frequency = "Weekly"
$query = "exec prc_ReportXYZ {0}, {1};"
switch ($frequency) {
"Weekly" {
$beginDate = $d.AddDays(-$d.DayOfWeek).ToString('MM/dd/yy')
$endDate = (Get-Date $beginDate).AddDays(7).ToString('MM/dd/yy')
}
"Monthly" {
$beginDate = $d.AddDays(1-$d.Day).ToString('MM/dd/yy')
$endDate = (Get-Date $beginDate).AddMonths(1).ToString('MM/dd/yy')
}
}
$beginDate
$endDate
$query = $query -f $beginDate, $endDate
$query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment