|
-
June 29th, 2001, 03:58 PM
#1
Dates
If I have date like "6/29/01" how do I get the date for the first day of the week (Monday)
which in this case would be "6/25/01" using VB code.
Kris
Software Engineer
Phoenix,AZ
Kris
Software Engineer
Phoenix, AZ USA
-
June 29th, 2001, 04:14 PM
#2
Re: Dates
Hello,
Weekday function returns the day of the week in numericals, i.e 1=Sunday.
Now using the Day function get the date i.e. 29. Now get the weekday of 6/29/01. Find the difference between 6/29/01 weekday and 2 (monday).
Subtract the difference from the day(6/29/01). That will be 4. Hence you will get the result as 6/25/01.
Thanks
Harini
-
June 29th, 2001, 04:26 PM
#3
Re: Dates
Using the weekday function, you can get a number that represents the weekday of the entered date. You can then use several available date functions described in the MSDN library to subtract a number of days from the date and get the first day of the week.
mydate = date(Now) 'get the current date
myDay = Weekday(mydate) 'get the weekday from the date
mynewdate = date(myDate - myday) '(?)subtract the number of days to get the first day of this week.(?)
I don't really know if that last line will work, but the Weekday function should at least give you a chance to find out the day of the week. I hope this info was useful!
-
June 29th, 2001, 04:48 PM
#4
Re: Dates
Maybe this would work
Dim datetoday As Date
datetoday = Date
Text1 = DateAdd("d", -1 * (Weekday(datetoday) - 2), datetoday)
David Paulson
-
June 29th, 2001, 05:22 PM
#5
Re: Dates
You're right: it works perfectly! Just convdert the Text1 to a date, and you have full functionality with the first day of the current week. Thank you, David!
-
July 2nd, 2001, 11:56 AM
#6
Re: Dates
That Works Great!!! Thanks So Much!!!
Kris
Software Engineer
Phoenix,AZ
Kris
Software Engineer
Phoenix, AZ USA
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
|