Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing Day for Date

Status
Not open for further replies.

mrf1xa

Technical User
Jan 14, 2002
366
GB
I'm sure this is a simple query for all those that know- but sadly I don't!

I have a table that holds dates in short date format. On the form based on this table I need to show not only the date but the day- preferably in a seperate text box if possible eg Monday 19/08/2002.

Any ideas please?

Thanks

Nigel Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Use the WeekDay function. Pass the function the date and it will return an integer where 1 is Sunday, 2 Monday, 3 Tuesday ... Then just display the weekday based on the value returned.
i.e.
Select Case Weekday(yourDate)
Case 1
TextBox.Text = "Sunday"
Case 2
TextBox.Text = "Monday"
....
End Select
HTH,
JC
 
Excellent, thanks a lot!

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Try this

****** Begin Code *****************************
Private Function DayFromDate(indate as String)

Dim mydate As Date
Dim myday As String
Dim weekno As String
Dim res As String

mydate = indate
weekno = Weekday(mydate)
myday = WeekdayName(weekno, False)
res = MsgBox(myday, vbOKOnly, "fyi")

End Function

******** End Code *************************************

Put this function in your form.
Call the function with a "date" argument
In other words ...
Call DayFromDate(mydatevalue)
This will pop up a message box with the Week Day Name.
Comment it out and add the control reference that you need.
Like This ...
Me.MyControl.Value = myday

Try that and let me know. I'm Your Huckleberry!
 
Heck - didn't know about the WeekDayName function -
All you really need to do is place a text box on the form and in the data->control source property enter
=WeekDayName(Weekday([YOUR_DATEFIELD_NAME))

Just replace YOUR_DATEFIELD_NAME with the name of the date field on your form and that's all you'll need

HTH,
JC
 
Why not just enter thew following in the format property of the text box:

dddd", " mmmm d", "yyyy

this will give you Thursday, august 22, 2002 today.

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top