July 25, 2018 at 4:09 am
((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM
(Get-Date -format 'Y')
gives me
July, 2018
How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018
Thanks
July 25, 2018 at 10:44 am
mtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Try something along the lines of: $SomeDate = (Get-date).AddMonths(1)
Get-Date $SomeDate -Format 'Y'
Sue
February 22, 2019 at 9:35 am
PowerShell uses the .NET format for date and time. You can look at https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings to see how t to use the build in standard formats. If you need something more custom, use this: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings.
February 22, 2019 at 11:32 am
mtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Ummm... use T-SQL instead? 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
February 22, 2019 at 11:52 am
Jeff Moden - Friday, February 22, 2019 11:32 AMmtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Ummm... use T-SQL instead? 😀
Odd as it may seem, a lot of times when someone posts a Powershell question in the Powershell forum they are often looking for an answer in Powershell.
Imagine that 🙂
February 22, 2019 at 11:56 am
Jeff Moden - Friday, February 22, 2019 11:32 AMmtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Ummm... use T-SQL instead? 😀
Powershell has better date formatting options than CONVERT 😛
February 23, 2019 at 7:19 pm
ZZartin - Friday, February 22, 2019 11:56 AMJeff Moden - Friday, February 22, 2019 11:32 AMmtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Ummm... use T-SQL instead? 😀
Powershell has better date formatting options than CONVERT 😛
"Better" how?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 23, 2019 at 7:22 pm
Sue_H - Friday, February 22, 2019 11:52 AMJeff Moden - Friday, February 22, 2019 11:32 AMmtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Ummm... use T-SQL instead? 😀
Odd as it may seem, a lot of times when someone posts a Powershell question in the Powershell forum they are often looking for an answer in Powershell.
Imagine that 🙂
Heh... I've been finding that, odd as it may seem, when someone posts a Powershell question in the Powershell forum, it's because they don't actually know enough about T-SQL nor how easy things can be there. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
February 25, 2019 at 1:38 am
Sue_H - Wednesday, July 25, 2018 10:44 AMmtz676 - Wednesday, July 25, 2018 4:09 AM((Get-Date).AddMonths(1))
gives me
Saturday, August 25, 2018 3:06:26 AM(Get-Date -format 'Y')
gives me
July, 2018How do i get August, 2018 when I run code in the month of July with the output in this format
August, 2018Thanks
Try something along the lines of:
$SomeDate = (Get-date).AddMonths(1)
Get-Date $SomeDate -Format 'Y'Sue
Or
(Get-Date).AddMonths(1).ToString("MMMM, yyyy")
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply