-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update request - How can I determine the Day of the Week #17
Comments
Hi 2 all, well this is just a try to see what's going on here and how to contribute here in a probably "expected way" :-) Powershell offers us a cmdlet called get-date which helps to answer most questions around date/time problems. "Get-Date -Date " is used here to first get the DateTime Type representation of your date entered as a string in the simplest form. So we could enter something here to get the required date:
The next step would be to get the real date out of our string "text" which might fail in many cases. That said: this kind of type conversion might be very easy to use but might "throw errors" But this one e.g.: OK, so we have to be aware of wrong input formats as users are always typing the unexpected and making programs abort with errors developers might not have ever seen in their lifes! If we have got a correct datetime, this type has some wonderful properties like these:
So we could use the "DayOfWeek" property and see if we like what happens:
Easy ... isn't it? A little console program to do the job might look like this:
I hope that this is something that might be expected as an answer to that issue! Have a nice day |
Good start |
@KES48 Would you be interested in submitting a PR to create this post? |
Summary of the update request
To get the day of the week, you use the DateTime's
DayOfWeek
property, or if you want a numeric result, usevalue__
Link to the post in the old blog:
https://devblogs.microsoft.com/scripting/how-can-i-determine-the-day-of-the-week/
Description of what needs to be changed:
Get a date in the past sho getting the date using Get-Date.
Then, get Day of Weel and the value
The text was updated successfully, but these errors were encountered: