We help IT Professionals succeed at work.

Identify day from date

1,318 Views
Last Modified: 2013-11-26
Hi.
I'm trying to Identify wihch day it is  from a date (YYY-MM-DD) .

I like to konw if the date is
1: Monday-Friday
2: Staturday-sunday
3: Public holiday (chrismas day etc)

Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
Dim dt as DateTime = Now
Select Case dt.DayOfWeek
   Case DayOfWeek.Saturday, DayOfWeek.Sunday

 
End Select
Top Expert 2007

Commented:
You can do it using the DayOfWeek property:

        Dim d As DateTime = Now()
        MsgBox(d.DayOfWeek.ToString())



Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Ok.. howabout the public holidays? like chrismasday and so on?

Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
Top Expert 2007

Commented:
You can create your own list if you want to, then just search the list to see if it's there:

        Dim holidayList As New List(Of Date)

        'Add Christmas and all holidays
        holidayList.Add(DateSerial(Now.Year, 12, 25))

        '** Using jpaulino's code:
        Dim dt As DateTime = Now
        Select Case dt.DayOfWeek
            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                ' Weekend
            Case Else
                ' Work Days
        End Select

        'Check to see if the date is a holiday:
        If holidayList.Contains(dt) Then
            'It's a holiday


        End If

Top Expert 2007
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thx guys..

I got an idea' of all this.. When the application starts I make a list of all holidays and save them to My.settings an then use VBRocks: and jpaulino's  code..

Author

Commented:
So is it possible to add a llistview with 2 columns  to My.settings?
Top Expert 2007

Commented:
Well, public holidays don't really change.  Is it a bad idea to hard-code them?

Author

Commented:
I will make a list for the user to chage add and remove public hollidays to a loist view and save this listviewto my.settings.

It's not often the public holidays changes here in sweden but it happens, so if I add them to my settings form they can change them by them self.

But I need to solve the problem with adding the two columns from the listview to my.settings

Listview
HolidayName  Date
aaaaaaaa      yyyy-mm-dd

Top Expert 2007

Commented:
Hold on.  You might just consider using a DataTable.  I'll post an example in a few minutes.

Author

Commented:
I will make a new question about this insted

thx for the help guys..

Author

Commented:
oki. thx.. I'll wait
Top Expert 2007
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
THX man!!!.. :)

Thank you all.. :)

Commented:


First thnx For [A] ... , 20  ;)


and glad i coulod help ... Happy Computing
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.