Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Calculating The Week Beginning Date.


Hi, I'm using the MonthView control for the first time, what I want to do is calculate the week beginning date on startup and when a person choses a date, i.e. todays date being the 29/03/2006 I need to enter the week beginning date of 27/03/2006 into a text box. I then plan to use this date to load information from an excel spreadsheet to fill in the AM and PM slots for the person, showing them their whereabouts for that week.

so if they choose another date, say 07/04/2006 it would select the week beginning 03/04/2006. Hope that makes sense and someone can show me what to do.

Regards.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculating A Date From Week Number & Year
I need to be able to calculate the date of every Monday depending on what week number/year it is.

For example is it possible to calculate the date (e.g. 20/10/2003) of a given day (e.g. Monday) when you only know the week number (e.g. 43) and the year (e.g. 2003)

If anyone can point me in the right direction, your help would be greatly appreciated.

Many thanks in advance

Jon

Access Report GroupOn = Week; How To Set MONDAY As The Beginning Of Week For Reporting.
Newbie here....

I need to create MS Access reports that use Monday as the beginning of the
work week where the data is grouped by week. I haven't found any code or
setting examples for Queries where I can do this. Any ideas?

Thanks in advance!

Beginning Of Week
How do you find the beginning and end of the week for any random date? with monday as the first day of the week?

also how, after doing this could you caption label with the dates of mon-fri of the week just calculated?

Thanks

Find Week Start Date From The Week Number
Does anyone know a way to find the start of the week from a given week number?

For example we are in week 32 this year and the start date is 2/08/04.

I have used the following to find the week number:


Code:
Private Sub getWeekNumber()
'This fantastic bit of code returns the week number

Dim iNumberOfTheWeek As Integer

iNumberOfTheWeek = DatePart("ww", Now())

End Sub

But now I want to find the date range that any given week covers.

Any ideas?

Calculating The Dates That In A Certain Week
Hello, I'm hoping somebody can help me with this. I'm trying to do the opposite to what's been posted in this thread previously: converting a date to a weeknumber.

I've got a line of code that's attempting to do this but apparently goes off somewhere as I'm getting the wrong weeks at the start of the year.
NewDayDate is the input date and WeekNum is the output:

Code:
WeekNum = Round(((NewDayDate - DateValue("1/1/" + Str(Year(NewDayDate)))) / 7) + 1, 0)

From what I've read above I should be using one of the VB constants as a reference instead of the Jan 1st that I'm using, but I cannot figure out how to sort this in a simple way. It seems as if I'm on the right track but I cannot seem to get it working properly.

Thanks for your help!

Calculating Start And End Of A Week
Hi All!

I'm new to this forum and I'd would just like to ask a question regarding calculating the start and end date of a week.

I'd like to show the starting and ending days of a week after the current date. Let's say the date today is November 17, 2003. I'd like my program to show November 24, 2003 and November 30, 2003 as the starting and ending dates of next week respectively. My week starts on a Monday.

I'm thinking of using the DateAdd function... Does anybody have any other ideas?

I'd really appreciate your help. Thanks!

How To Get The Week Of A Particular Month And Then Search For The Date In That Week?
Hey guys, I have a problem here. I am at da moment, trying to code the form where I can calculate the week's Statistics of the booked dates in the file.

All Im tryin to do is the user has access to the months 1 - 12 after he clicks on the combo box. after that he can choose the first second or last week from another combo box after this he will be shown the no: of bookings done in that week.

I cant get it working. I got it to 2 work on the month and week by adding them to da combo. but not the process.

please help

Darkshade

Week Number And Week Ending Date In VB 6
Hi,
I'm trying to get the system's week number and its week ending date using the VB FORMAT function. For the week number is pretty simple and it works fine but its week ending date I can't find the function. It has to be a function for this instead of codes.

For my week number is this:


test1 = format (date, "ww") 'it gives me the current week number (numbers from 1 to 52)


Now from that week number I would like to get the week date ending, eg.

for week 19 its ending date would be 05/10/2003 (Saturday May 10, 2003)


Any ideas?


Thank you

Olivia

** RESOLVED ** Calculating Financial Week (still!)
I am using the following code to calculate the financial week for a particular date. Sometimes this routine works, and sometimes it doesn't

For example, assuming that rs.Fields!RMSH_DFN = "20020509", the end result (REP_DATESENT) is "06 /0" ???!?!?!


VB Code:
If Val(rs.Fields!RMSH_DFN) <> 0 Then        tempString = Mid$(Str$(rs.Fields!RMSH_DFN), 8, 2) & "/" & Mid$(Str$(rs.Fields!RMSH_DFN), 6, 2) & "/" & Mid$(Str$(rs.Fields!RMSH_DFN), 2, 4)        tempDate = tempString        tempWeek = DateDiff("ww", "1/1", tempDate) + 1        tempYearNo = Mid$(Str$(rs.Fields!RMSH_DFN), 4, 2)        If Val(tempWeek) < 14 Then            tempWeek = Format$(tempWeek + 39, "0#")            tempYearNo = Format$(tempYearNo - 1, "0#")        Else            tempWeek = Format$(tempWeek - 13, "0#")        End If        Rep_DateSent = tempWeek & "/" & tempYearNo    Else        Rep_DateSent = "NSO"    End If


I'm doing a bit of manipulation to display the end result as "WW/YY" by the way.

I just don't get why it works woth some dates and not others ?!

Anyone like to point out the error of my ways ?

Date Of First Day Of The Week From A Week Number
Does anyone know of a way to get the date for the first or last (It really doesn't matter) day a week given a week number?
I'm calculating the week number by using:


VB Code:
lcurrentweek = format(Now, "ww")lcurrentweek + 1...lcurrentweek + 9 'Then i'd like to find the first or last day of each of those  


I guess since I'm just trying to get the first dates of the next nine weeks that i could just find the first date of this week and keep adding seven too it?

Thanks
Andy

Finding The Date Of The 2nd Day Of The Week Of Week 44
how can i find the above?

e.g i want to find for weeknumber 44 what is the date of monday

thnks

Resolved VB Code FOr Calculating Working (week Days) Including A Holidays Table.
Hi All I am try to create a function which will calculate the net working days between two dates, not including public holidays. I borrowed code but I am unable to get it to work, and NetWorkingDays MS in built function does not work either. (holiday table has two columns ROWID, HolidayDate d/mm/yyyy

Here is the code can anyone please help.


Function WorkingDays2() As Integer

On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Dim Startdate As Date
Dim EndDate As Date

Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)
'holiday table has two columns ROWID HolidayDate dmmyyyy
'StartDate = StartDate + 1
'To count StartDate as the 1st day comment out the line above

Startdate = [tblEnquiries].[Date Received]
EndDate = [tblEnquires].[Date Completed]

intCount = 0

Do While Startdate <= EndDate

rst.FindFirst "[HolidayDate] = #" & Startdate & "#"
If Weekday(Startdate) <> vbSunday And Weekday(Startdate) <> vbSaturday Then
If rst.NoMatch Then intCount = intCount + 1
End If

Startdate = Startdate + 1

Loop

WorkingDays2 = intCount

Exit_WorkingDays2:
Exit Function

Err_WorkingDays2:
Select Case Err

Case Else
MsgBox Err.Description
Resume Exit_WorkingDays2
End Select

End Function

 

Edited by - bmwtiger on 6/29/2005 11:35:35 PM

*RESOLVED* Given A Date Return The Date Of Monday The Same Week
I'm stumped. The title says it all.

I need the date of Monday for the same week as any date entered. I'm using the system settings for the first day of week.

For some reason I can get it to work unless the day selected is the first day of the week. In that case it always selects the monday of the previous week. For all other dates it works fine.


VB Code:
dMonday = DateAdd("d", -Weekday(dSelectedDate, vbMonday) + 1, dSelectedDate)

Computing Date From Mix Of Date &amp; Week Number.
I am given a date in the form month/Week Number/Year. (Why it's being passed like this is a whole other matter)

So, 01/03/2006 would mean "The 3rd week in January", 02/04/2004 would mean "The 2nd week of Febuary"...

Does anyone know of a quick & dirty way of converting this to a standard date? We're looking for something that goes to the first day of the specified week, in our case Sunday.

So 01/03/2006 would convert to 01/15/2006
02/04/2004 would be 02/22/2004

Any ideas would be appriciated & Thanks.

The Day Of The Week Corresponding To A Date
Hey. I'm sure this is easily done, but if I get a month and a year, how could I be able to figure out which day the first of said month fell on? For example, if I were to receive November, 2006, I'd want to know that Novumber 1st falls on a Wednesday.

Date (week)
I have a field in my database and want to update this field with a value
choosen in a combobox.
An example :
date = 10.08.2004
cboweek.Text = "5" (35 days)
newdate = 14.09.2004

Can I use DateAdd ?.......how ?

Can someone pls help me with this code ?

Day Of The Week From Date
I'm sorry if this has been asked before but I have had a hard time finding it with the search.

I need the basic algorithm to find the day of the week based on the date. I have it working for the 1900s but not for al years. Im not asking for the code just the basic algorithm if anyone knows it or knows of a site that has an example.

for example if given 03 12 03 it would return Wednesday

Thanks!

James

Date To Day Of Week
Hello,

I have a very important procedure to add to my program and I can't figure out how to do it.

I simply want to convert a given date E.g. 11/06/2003 (dd/mm/yyyy) to the day it corresponds in this month for this year. I.e in this case Wednesday.

Anybody has an idea please.

Thanks

Mark

Get First And Last Day Of The Week Using Date
Hi All,

First of all, i would like to thank everyone for being with vbforums.
It's a great place to be and have so much information available.

I am writing an automated report generator and i need to tell it to run reports at the end of each week for the week before


I have already managed to get the 24 hour reporter working and the monthly reports.
but for some reason i can't work out the weekly thing.

Please, I am open to any suggestions.

Elpower

Getting The Date Of A Week
ok, here's a challenge for you! then again it might be piss easy, but it's extremely hot in the office, and i can barely concentrate on anything

say i had a combobox with a list of week numbers (ie. 1, 2, 3,.....52), how could i select a week number and get the date that week started? so if i selected week 1, it would return 01/01/01, and week 2 would return 08/01/01, etc.

thanks

Getting Date Of The First Day Of The Week
thanks i also just came up with this, although i haven't tested it properly yet:


VB Code:
Public Function Blah()    Dim i As Integer        For i = 7 To 1 Step -1        If (Format(DateAdd("d", -i, Date), "ddd") = "Mon") Then            Blah = DateAdd("d", -i, Date)            Exit For        End If    Next i    End Function


i think i'll do it your way though, looks safer

How To Know The Week Of A Date?
Hi, can any body help me?
Is there a function or whatever wich can tell me the exact week number from a given date (for example: 01/01/2001 is in week number 1).
Tanks!!!

Get Date From A Week Ago
Greetings and Salutations!

I would like to know how I can get a date formatted minus seven days from todays date and also one month prior.

Thank you for reading this and any help you can provide.

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

Get The Date Of The First Sunday Of The Week
Hi,

I will pass the week num ( 1/2/3/4/5) and week day(1/2/3/4/5/6/7)
for a date varaible.

I need to get the date of the first sunday or second sunday or first monday
or second monday of the month.
As per the parameters passed above , I need to get the date values.
Any VB functions to get this.

Pls let me know reg this ..

Thanks,
ksk

How To Get The Week No In A Year Given The Date
i would like to know , what functions that need to be used in order to get the week no in a year given the date..

i tried using the week(date) function but it does not seem to work..is there any other way i can solve this problem..tahnk you..

regards pragash..

Finding What Day Of The Week A Date Is
I was wondering how you can find out what day of the week a date is. For instance, I know 4/16/01 is a Monday. Is there anyway for VB to tell me what day of the week any date I feed it is?

Whom shall I fear?

Date To Week Function
Here's a function that translates week to date:

Public Function StartOfWeek(txtWeekNo As String, txtYear As String) As Date

Dim TempDate As Date

TempDate = CDate("01/01/" & txtYear) - Weekday("01/01/" & txtYear, vbSunday) + 1


TempDate = TempDate + 7 * (txtWeekNo - 1)

StartOfWeek = TempDate

End Function


How can I translate date to week(with the year of course)?

Date Functions(beg. And End Of Week)
Is there a date function(s) that will return the first and last date of the week based on a date that I give it?

Week Number --&gt; Date?!
What I wish to do is this:
User selects a week number, and a combobox is filled with the dates (monday through sunday) corresponding to the specific week. For example the user selects week 43, and the combo contains this:
Monday 21-10-2002
Tuesday 22-10-2002
...etc...etc
Sunday 27-10-2002

Any suggestions?

(I live in Denmark, and therefore the first day of the week is vbMonday)

Calendar Week To Date
Guys this is urgent! Please help.
I need to convert a calendar week no into a date (Saturday).
I did set the first Saturday of the year into a formula (as below). But the output is all Sundays.
sWeekEnding = DateAdd("d", ((rst2!CalendarWeek * 7) - 2), rst5!firstsaturday)

Please help. Is there any other formula that I can use?
Thanks.

Getting A Date From A Week Number
Is there a function in VB to return Month/day from a week number - where current year is also entered ?

Give Me The Date From The Week
Is there a way to give me Sunday's date on the 11th week of this year in this formatt?

dd/mm/yyyy

thanks

Type In Date Get Out Week No.?
Simple Form:
Textbox --- you get type in f.ex. 03.09.01 and you will get in msgbox the week no. in this case week 10 of 52 !
can anybody help?

How To Get Week Days From A Date In Vb6
Dear,

I have to change the days of the week from satureday to sunday and sunday to satureday. Is there any function which can impliment it.

regards.

How Do I Get A Week Number Out Of Date?
That is my problem. I read a date (ie. 14.10.2004) and I need a function, which tells me which week number that day belongs (in this case, week 46). Any idea is appreciated. Thank you.

- - - - - - - - - - - - - - - - - - - -
 Long days and pleasant nights
   - Roland the Gunslinger
 - - - - - - - - - - - - - - - - - - - -

Calculating A Date From Date And Integer
I have a base date and an offset (number of days). I need to get the date
represented by that number of days after the base date.

Date math help, please.

what I need to do is:

newdate (mm/dd/yy) = somefunction?( basedate (01/01/2000) + offset
(integer))

Mike Morrow
Acxiom Corporation
Abilitec Services Group
(501) 342-0170
mailto: email@removed
Office: CWY0204111
M/S: CWY024 - 19

Determining What Week A Date Falls In
I have a small program that I am creating that will prompt the user to enter a date in the format mm/dd/yyyy. Is there anything built in VB that will allow me to find out which week of the year the day falls in. Im assuming that VB assumes that Sunday is the start of the week.

An example of what I am trying to do would be the following.

The user enters the date 01/05/2006. And the program would know that the date entered is in Week 1 of the year. I am trying to get this so that it will work moving onward for any year in the future.

Any ideas or starting points on where to begin with this.

Thanks

Calculate Week Ending Date
can anyone tell me how I can calculate the End of week date?

I want to have a comb box that the user can pick a date, ( all Fridays date for the year)

I dont have a clue as how to do this


Dale S

Test If A Date Is In The Current Week
I'm trying to make a little function that checks if the date in the database is in the current week and then if it is, I could add the entry on a listview.

Here's a concrete example of what I'm trying to do:
Let's say an entry has the date May 8th 2007. I want to test if Now is in the same week as the entry. (Now could be a date from May 8th to May 12th (can't go in the past naturally)).

Weeks start on monday too.

I've tried a lot of things to make it works, but I still didn't succeed, that's why I'm asking you guys...

If someone could help me with this I would really appreciate it.

Thanks in advance.

Select Week, Display Date... How?
How do I do in such a way where i choose the week and the date within that week is displayed?

Calender Control - Date YES But Which Week ....
Hi there,

I'm trying to figure out if it is possible to use the Calender control and somehow when you click the date can also find the week of that date (say it's "date = week 32 of the 2006) just like in a dairy. If it has to be any other control fine, but I would prefer the Calender cntrol to work with.

Thanks aktell

Obtaing A Week Number From A Date
How can i obtain the week number from a given date.

At present this is week 5.

Any help would be appreciated

Date From Week Number --RESOLVED--
I am saying the first week number is the week which the first of January is in, and the week starts on a saturday.

I am recording login's in a database using the date but want to search it using the week number.

Is there any way which i can get the start and end dates of the week number so i can search the data using these as parameters.

to get the week number i am using the datepart function.

Any help is much appreciated

About Date Record Is 1 Week Older.
Hi,

How can i delete a record using timer in a specific date like a record is 1 week older.

ex:

delete from table where date=""

Can any one help me.

Determine Date Out Of Week And Year
Hi,

Is there a function, or is it difficult to make a function, that receives 3 parameters (weeknumber, year and day) and determines the date belonging to that day. For example I want to know what date the friday in week 23 in 2003 will be. I pass these parameters to the function and it returns: "June 30".

Does anyone has suggestions an making such a thing?

How Would You Calculate A Week Ending Date?
Anyone have any code that would calculate a week ending date if the W/E day is Sunday?

Thanks,
Jeff

Receiving A Date From A Week Number?
Does somebody now what function or does someone have some code for receiving
a Date when my input value is a week number?

I will appreciate any help.

Day Of Week To Actual Date Dilema
I am working on a delivery service model. I have to deliver freight on certain days to certain stores. I have a table that has store information and what day of the week they should receive freight. Once the Truck is loaded I generate an email that the truck is loaded and ready for pick up. The problem I am having is to add the delivery date based on their Delivery day. For example

Store "ABC" gets deliveries every Wednesday.

I finish loading the truck today 04/23/04
I need something that will look at "Wednesday" as the delivery day in my store table and display a message saying that this will deliver on 04/28/04.

Anyway to do this???

All suggestions greatly appreciated
Thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved