|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How i can get the name of the day a particular date using vb?
How i can get the name of the day a particular date using vb?
|
|
#2
|
|||
|
|||
|
Here is a quick way to do it in VB
Code:
Private Sub Form_Load()
'Insert today's Date in the textbox
Text1.Text = Date
End Sub
Private Sub cmdDay_Click()
Dim daynum As Integer, sweekday As String
'Figure out the day
daynum = DatePart("w", Text1.Text)
Select Case (daynum)
Case 1
sweekday = "Sunday"
Case 2
sweekday = "Monday"
Case 3
sweekday = "Tuesday"
Case 4
sweekday = "Wednesday"
Case 5
sweekday = "Thursday"
Case 6
sweekday = "Friday"
Case 7
sweekday = "Saturday"
Case Else
sweekday = "unknown"
End Select
Text2.Text = sweekday
End Sub
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
Attached is the full sample
|
|
#4
|
||||
|
||||
|
In ASP there's a function called WeekdayName() - so chances are you'll have it in VB too.
WeekdayName(weekday, abbreviate, firstdayofweek) - where "weekday" is an int, abbreviate is a boolean (yes/no), and firstdayofweek defines the starting day of the week (Sunday is the default) |
|
#5
|
|||
|
|||
|
Thanks Stumpy:
That simplifies the code a lot: Code:
Private Sub Form_Load()
'Insert today's Date in the textbox
Text1.Text = Date
End Sub
Private Sub cmdDay_Click()
Text2.Text = WeekdayName(DatePart("w", Text1.Text), False)
End Sub
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > How i can get the name of the day a particular date using vb? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|