header1   header
header
header : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
IMPORTANT: PowerShellCommunity.org is moving! - Wednesday, August 15, 2012

PowerShellCommunity.org is moving!  This community software, and the hardware that it sits on, are no longer serving the purposes of this community.  As a result, we have decided to move this community to a new home at PowerShell.org.  PowerShell.org is already up and running with the new community software and in its new location, so please post any new questions that you have on the forums over there instead of posting them on this site.  We've already started getting some great questions from members of the community over there so please, come on over and join us!

While we are going through this transition, this site will remain up for the short term.  New posts may no longer be created on these forums, however replies to existing posts are allowed so that users who posted questions don't have to re-post the same question on the new site.

[UPDATE 28/02/2013] New user registration has been disabled and forums have now been switched to read-only, including for existing posts since all threads that were started should now be completed. If you have a question about content on this site or about PowerShell in general, head over to PowerShell.org and ask it there where there are people actively using the site and answering questions.

If you have any questions, please let us know on the PowerShell.org site.

Thank you,

Kirk "Poshoholic" Munro

 
IMPORTANT: PowerShellCommunity.org is moving! - Wednesday, August 15, 2012

PowerShellCommunity.org is moving!  This community software, and the hardware that it sits on, are no longer serving the purposes of this community.  As a result, we have decided to move this community to a new home at PowerShell.org.  PowerShell.org is already up and running with the new community software and in its new location, so please post any new questions that you have on the forums over there instead of posting them on this site.  We've already started getting some great questions from members of the community over there so please, come on over and join us!

While we are going through this transition, this site will remain up for the short term.  New posts may no longer be created on these forums, however replies to existing posts are allowed so that users who posted questions don't have to re-post the same question on the new site.

[UPDATE 28/02/2013] New user registration has been disabled and forums have now been switched to read-only, including for existing posts since all threads that were started should now be completed. If you have a question about content on this site or about PowerShell in general, head over to PowerShell.org and ask it there where there are people actively using the site and answering questions.

If you have any questions, please let us know on the PowerShell.org site.

Thank you,

Kirk "Poshoholic" Munro

 
Another date formatting question
Last Post 11 Apr 2011 12:48 AM by mushroomning. 4 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
graysonUser is Offline
New Member
New Member
Posts:9
Avatar

--
14 Feb 2011 12:59 PM
    New thread - similar question.

    I'm attempting to perform actions on files created on the FIRST day of the last month.

    The format for the name pattern I need is: yyyyMM01

    Ex: 20110101

    Shay Levy provided this response when I first posted my question:

     ToString() method:
    (Get-Date).AddMonths(-1).ToString('yyyyMM')

    However at that time I didn't realize I needed to append 01 to the results.


    vstarmanvUser is Offline
    New Member
    New Member
    Posts:17
    Avatar

    --
    14 Feb 2011 03:50 PM
    first day:
    (Get-Date).AddMonths(-1).ToString('yyyyMM') + "01"

    today:
    (Get-Date).AddMonths(-1).ToString('yyyyMMdd')
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    14 Feb 2011 10:32 PM
    First day of last month (returns datetime object):

    get-date (get-date).addmonths(-1).tostring('yyyy/MM/01')

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    graysonUser is Offline
    New Member
    New Member
    Posts:9
    Avatar

    --
    15 Feb 2011 03:30 AM
    Thanks again for the quick response
    mushroomningUser is Offline
    New Member
    New Member
    Posts:7
    Avatar

    --
    11 Apr 2011 12:48 AM
    may be i am wrongf,but i hope you can give me a opportunity !!especially the board administator!! if i do not get this message successfully i will be fired!!i need money to keep my mother!!!!
    3x!!!!!3x!!!!
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Many thanks to our original sponsors: Quest Software • SAPIEN Technologies • Compellent • Microsoft footer
    footer   footer