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.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Week Numbers & Week Days
I have a project where I need to find the week number ( say Jan 1st to Jan 6th is Week#1, Jan 7th to Jan 13th is Week#2)
also How can I find the day of the week, How do I find whether Jan 1st is Monday or Sunday.
Anybody ?
Days Of The Week
Hi,
I want to run an application using the timer and the day of the week, I don`t want the application to be launched over the weekend,just monday to friday.
for example'
if Day<>saturday or Day <> sunday and time = 12.00 then launch program
else
end
I`m very new to VB so don`t know the code, the above is just my theory of what I would like. I would be very grateful if somebody could convert this to VB.
thanks in advance
jono
Days Of The Week
hi,
if today is 01/01/06, how can I be able to display the list of the 5 following days (01/02, 01/03, 01/04, 01/05 and 01/06), and the 7 days of week?
please help how!!!! Thank you,
Week Days
I'm wanting to compare two dates for example 01/06/04 and 17/06/04 and count the number of week days between those two days (excludes Saturday and Sunday). What would be the best way of doing this?
Days In Week
Well you can easily find the day of a specific date by doing this
VB Code:
'This returns 1 for sunday, 2 for monday, 3 for tuesday etc tempdate = Day(DateToCheck)
Does that help?
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?
Count The Week Days Only In Excel
I had to create this function to count the week days (minus saturday and sunday) between to dates.
Function GetWorkDays(StartDate As Long, EndDate As Long) As Long
' returns the count of days between StartDate - EndDate minus Saturdays and Sundays
Dim d As Long, dCount As Long
For d = StartDate To EndDate
If Weekday(d, vbMonday) < 6 Then
dCount = dCount + 1
End If
Next d
GetWorkDays = dCount
End Function
I then have to call it from a cell with: =GETWORKDAYS(startdate,enddate)
Is there a way to do it with a formula? I dont want to create the module in every worksheet I create. I have a lot of users that will use this function, so the simpler the better.
Flexgrid And Order Days Of Week Help...
hi all
I'm fairly new to VB, and I'm currently using this flexgrid and trying to create some code so that I can select a weekday from a combo box (i.e. Monday to Sunday)
I want to be able to select the day and then from that I want to order the rows of the flexgrid starting from the day selected from the combo box
e.g. If I select Thursday from the combo box I want to be able to click a button or something so that in the flexgrid the labels on the rows order as follows:
Thursday
Friday
Saturday
Sunday
Monday
Tuesday
Wednesday
I hope from that you can understand what I'm talking about?
I've tried to start working out how to do this by loading the days into a listbox with this code in the command1 button...
Code:
List1.Clear
Dim x%
Dim q(0 To 6) As String
q(0) = "Monday"
q(1) = "Tuesday"
q(2) = "Wednesday"
q(3) = "Thursday"
q(4) = "Friday"
q(5) = "Saturday"
q(6) = "Sunday"
For x% = 0 To 6
If Combo1.Text = q(x%) Then
List1.AddItem q(x%)
Do While x% < 6
x% = x% + 1
List1.AddItem q(x%)
Loop
End If
' Also tried something in here to show all the other days, but it didn't seem to work no matter what I tried
Next
If someone could help me with some code with this, but so I can load it into a flexgrid using FG1.TextMatrix(>row<, >col<)
cheers all
treelovinhippie
Calculate Days Of The Week For A Given Month
I'm doing a project for school and needed help on figuring this one out. We have to come up with a program able to accept a year and a month. Then calculate the days for that specific year and month and place the information into a text box. I have the validations for the txt strings no problem. But how to go about retrieving dates? Gee wiz.... did you guys have this much trouble starting out? We went over in class the commands for year(date), day of week(date), and month(date). But basically all that was given was the command. We did one example for listing leap years for the past decade. Interesting to say the least. Please help!
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
Retrieve Dates For All 7 Days Through Week Number
Hi all.
I made the following on a vb form using labels and textbox controls (my apologise for not getting the alignment right down here!):
Week nr.:
Monday Tuesday Wensday Thursday Friday Saturday Sonday
Date
Hours 8 8 8 7 5 4 0
This will be used to enter the number of hours that an employee has works that week.
Question: how can I automaticaly let VB insert the right dates in the Date-column when a user has entered the week number?
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
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)
Date Format, Count No. Of Days & Highlight Date In Calendar
<html><div style='background-color:'><DIV>
<P>Hi all,</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Happen to visit this website accidentally and found that it’s very useful to VB beginner like me. <SPAN style="mso-spacerun: yes"> </SPAN>I have the following problems and would appreciate your kind assistance to enlighten me.<SPAN style="mso-spacerun: yes"> </SPAN>Attached is my file for your checking.<SPAN style="mso-spacerun: yes"> </SPAN></P></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <?XML:NAMESPACE PREFIX = O /><O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">1)<SPAN style="FONT: 7pt 'Times New Roman'"> </SPAN>Sometimes, the number of days is incorrect with a big figure (e.g from 1 to 30 Apr) or even a negative figure after I change the system’s date format from “mm/dd/yyyy” to “dd/mm/yyyy”.<SPAN style="mso-spacerun: yes"> </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; tab-stops: list .5in; mso-list: l0 level1 lfo3">2)<SPAN style="FONT: 7pt 'Times New Roman'"> </SPAN>In calculating the number of days, I need to exclude Sunday.<SPAN style="mso-spacerun: yes"> </SPAN>By using the “WeekDay (Calendar1) = 7 “ method, I still didn’t get the correct result.<SPAN style="mso-spacerun: yes"> </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P> 3) How to highlight a certain date in calendar with different colour to indicate it's a public holiday ? </O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P></O:P> </P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Many thanks in advance.<SPAN style="mso-spacerun: yes"> </SPAN></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <O:P></O:P></P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Best regards,</P>
<DIV></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">YC </P>
<DIV></DIV>
<DIV></DIV>
<P><BR><BR></P>
<DIV></DIV>
<DIV></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMVEN/2746">MSN 8.</a> Get 2 months FREE*.</html>
Using The DATE To Transmit 2 Days Ahead Of Current Date (RESOLVED Thank You)
It seems simple, ive looked and looked, cannot find it. . .
basically what I need to do is transmit 2 days ahead of current date. . .
IE today is the 14th, I need it to auto transmit it to the 16th.
Its a pend out date on an account, I've got everything auto except for this feature. . . .
If I get in touch with a client, I want the account to automatically pend the account out for 2 days.
Thanks for the help, love the site, look for me more often, and be sure to purchase some of my award winning albums at a christian store near you.
Edited by - Bryan Duncan on 6/15/2004 3:52:58 PM
Computing Date From Mix Of Date & 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.
Check If Today's Date Is X Days Past Another Date
Hi, I am using Visual Basic 6.0 on Win 2000 environment. I am currently developing a video rental app as a school project. How can I check and see how many days past today's date is from a previously entered date?
For instance, 1- When a customer rents and item, I enter the customer's rental date (let's use 5/20/04 as an example), 2 - Then when the customer returns the item, I enter in the date returned (5/23 - today's date). How can I code this in VB to check for how many days late the item is?
I tried doing this, but nothing happens: (let's assume the variable dateRented is the date that was previously entered when the customer rented the item)
VB Code:
Dim todaysDate As DatetodaysDate = Now If dateRented > todaysDate Then MsgBox "This item is late!"End If
Any suggestions would be great. I appreciate it!
Date Function Minus Days From Date
I think the title says it all but I just want to minus daysTillLastSat from the date so that I can find out what the date of last Saturday was from any specific point in time and space well time mainly. Any ideas?
Code:
Function weekMaker() As Integer
For i = 1 To WeekDay(Now())
daysTillLastSat = daysTillLastSat - 1
Next i
If daysTillLastSat = -7 Then
daysTillLastSat = 0
End If
MsgBox "DAYS BACK TILL SAT + " & daysTillLastSat
MsgBox Now() - WeekDay(daysTillLastSat)
End Function
Start Date + End Date = Amount Of Days
Hi Guys
I have a simple question that i cant quite figure out, what i have is.
3 text boxes namley "Text2" "Text3" and "Text4" Text2 gets a start date say
01/10/2005 and text3 an end date say 30/10/2005 then in Text4 the amount of days displayed is 30. I just dont know how to get the 30 displayed in Text4.
It should be pritty easy but i have hit a blank, please help.
kind regards
Working Out A Date By Adding Days To Another Date
hi,
I have a date and number of days.
I'm trying to work out the date that comes out of adding the days to the original date (bringing into account months and end of year etc.)
would simply adding the days to the date do the trick (Date = MyDate + Days) ?
thanx
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)?
Week Number --> 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.
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 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
- - - - - - - - - - - - - - - - - - - -
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.
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
|