|
-
January 17th, 2000, 05:22 AM
#1
Date of the first day of a week
Hi everybody
I want to know the date of the first day of a week.
Example: I choose a date : the 5th of MAY 2003.
I can have the week (between 1 and 52)
But I want the date of the first day of this week.
I can get the day (monday, tuesday...) and if I know how many days there are in the month I can move backward until the first day.
Is there a method faster and easier than this one???
Fzz
-
January 17th, 2000, 05:52 AM
#2
Re: Date of the first day of a week
you need to deduct the day of the week from the date and this gives you the first day of the week for that date.
try this
[vbcode
Dim lDay As Long
If IsDate(Text1.Text) Then
Text2.Text = (CDate(Text1.Text)) - (Weekday(Text1.Text) - 1)
End If
[/vbcode]
hope it helps
jonathan
-
January 17th, 2000, 05:54 AM
#3
Re: Date of the first day of a week
assuming date is in a variable "dtIn" then:
DATEadd("d",0-((datepart("w",dtIn))-1), dtIn)
is about as short as I can get it.
HTH,
Duncan
-
January 17th, 2000, 07:22 AM
#4
Re: Date of the first day of a week
If you use DTPicker control for the input of the date value, then check out the property "DayOfWeek". Maybe this helps.
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|