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

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!

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can You Get The Date 7 Days Before Today?
Anyone know how to do this?
Does VB have a function to handle things like this built in or will I have to code a complicated function :P?

Subtracting 10 Working Days From Today's Date
How would I go about finding the date that is 10 working days prior to today, starting yesterday? Working days being Monday - Saturday, bank holidays aren't important.

Eg. If you entered todays date, it would return 26/07/2008


Check For Date Today?
Hi Folks

Im currently trying to:

1) On a certain form loading, check my database for ANY entries where a date matches current date
2) If this occurs, notify the user saying "you have a diary entry for today, go and check it"
3) My field I want to check only holds dates....generated and added via the Date picker so all are valid

Now, I try to check this and heres my code:

Set dbMyDB = OpenDatabase(App.Path & "/mydatabase.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("calendar", dbOpenDynaset)

If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
If rsMyRS!Date = Date Then MsgBox "Diary entries exist for today"

This doesnt seem to do the trick - obviously I must open the db which the first2 lines take care off, tried to dump in a loop a check that checkcs all entries for todays date using the DATE variable (Which is todays date yes?) and if it finds a date matching today, tell me!

But, it does nothing...if anyone can help, Id be most grateful!


How Do I Check If A Date Is Less Then 120 Days?
Ok, this one is beyond me. None the less, I need some guru help to accomplish this. This is where your expertise comes in...

I have SQL statement retrieve a Date from a field in an Access database to be displayed in a textbox txt(2).Text. This particular date is an expireration date. I need to check to make sure that this date is not less than 120 days. If it is I will have my code mark it as RED to the user.

I already have my SQL statement working fine for retrieving the specific date and displaying it in txt(2).Text. My issue is that I do not know the proper coding to check if the specific date is < 120 days.
I am using VB6 for all my coding needs.

Thank you all for your time and efforts,

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>
<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>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"> <O:P></O:P></P>
<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>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> </P>
<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>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><O:P></O:P> </P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Many thanks in advance.<SPAN style="mso-spacerun: yes">  </SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"> <O:P></O:P></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Best regards,</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">YC </P>
<DIV></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="">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

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?

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
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) ?


Today's Date
How can I get vb to show today's date / put it in a label? I don't know date commands! Also, if you subtracted one date from another, what unit would the answer be in?

Today’s Date
Good Day,

I would like cell A1 to always hold today’s date in the format MM/DD/YYYY.
How can I do that?


Today Date In SQL
hi all.. how do i reference today's date in sql?

Getting Today&#039;s Date
how do you get today's date, and what day today is. I'm pretty sure there's a simple way to find this out. The information I need is the month, date, year and the day of the week, like sunday or monday... help needed asap

Date In VB6 = Today In VB.Net
In VB6 today is extracted with Date, i.e.
Today = Format(Date, "mmddyyyy")

Getting The Date Today(access)....
hi! can someone please help me?

i am trying an sql statement that will return to me records whose dates are dated today. i used the =Now() but it won't work. I also used =6/19/03 but it also won't work. for both cases, there were no compile time errors but when i run the statement, it didn't display any records. Thanks a whole lot in advance!!!

Save As (Today's Date)
Hi, I'm trying to write a code that will open up a file and save it as today's date. ex.) (290703.txt). This needs to be done daily. Is there anyway that I can get the filename in the save as line to equal today's date. I was thinking of using a variable somehow but I'm not too sure how to do this, or if that is possible? Thanks!!

Get Today's Date In String
Right now I have this string to pull in today's date but for some reason the DD is not recognized. I get 200502DD0330. Can someone tell me how to get this to print out the day to 2 digits? Everything else works just fine. Thanks.

strXferTimeStamp = Today.Year & Format(Today.Date, "MM") & Format(Today.Date, "DD") & Format(Now, "HHMM")

How To Get Today's Date.... This Month Name And...
Here are my simple questions

Q1. How to get Today's Date in VB6 ?
Q2. How to get This Month's Name ( Like December ) ?
Q3. How to get Today's Day Name ( Like Saturday ) ?

thanks in advance

Get Today's Date Only (dd/mm/yyyy)
I wanna run a query like this:
Select * from Data where Date&TimeOrdered=Today's date

How do I get today's date in a manner understood...

Tomorrows Date Today
Hi Everyone,

How do you display tomorrws date today inside of a label control. For example, today's date is February 26, 2001 so the label would show February 27, 2001. Thanks for any help.

Save As Excel Today's Date
Using Excel VBA 2003 How do I save as todays date in the P:/security/ drive and close the application after clicking on a command button.


Change From TODAY() To Real Date
I'm curious if there is an easy way to enter today's date into a cell, without using the "TODAY()" function.
The reason I ask - I am setting up a template that, when started, should automatically insert today's date into a cell. However, I want that date to stay stationary after the workbook is closed and re-opened.

In other words, if someone starts a new workbook based on that template today, the date would be entered as 05/18/2005. If they save the workbook and open it again next week, I want the date to still be 05/18/2005 instead of becoming 05/25/2005. Is there an easy way to accomplish this?

I've thought about having a hidden cell where I store a value letting me know whether the workbook has been saved before or not, and then setting up a macro that will enter today's date into the appropriate cell if the workbook has never been saved, but the macro won't do anything if the workbook has been saved. This seems like a lot of work, though. If there's an easier way to accomplish the desired goal, I would love to hear it.


Creating A File With Today's Date
Is creating a file with today's date as a name possible? If it is, how plz?


Monthview Showing Today's Date
The following code works,

VB Code:
Monthview1.Value = Now

But how can I set it so that "NOW" does not display a datetime. I want the date in a format like "YYYY/MM/DD".

I tried the "Dateformat property" of the Monthview control but notta.
I am getting ready to try trimming the time of the end manually, but I'm certain there is an easier way.

Cant Have Today Date Or Is My Code Wrong....
when i press the command button, today date will appear in my text box... is there anything wrong with my code....
If there is, can help me... Pls help...

*Addseen is my text box name.
**DATE is the field in my DB

        Addseen.value = Format(DATE, "Short Date")

Calculating Time Between A Future Date And Today
I'm stuck again!I'm a real noobie..sorry!


i'm creating a booking appointment system and i need to calculate the time in between today and a future appointment.

i know i have to use Date Diff but have no idea on how to use it .

im using VB6 and the date is in Access and i have all the ado controls set up etc.

any help would be gratefully accepted.

How Do I Input The Today's Date Into A Text Box Automatically?
okay,, I am an idot. How do get the date from the system clock so I can use it as a variable? variable name most likely "varDateEntered"

HAPPY NEW YEAR ALL!!!...Have You Noticed The Date Today 01/01/01.
01/01/01 Must mean this is the actual millenium as the date has reset?

Probably An Easy One--how To Autofill A Form Textbox With Today's Date.
Subject pretty much says it all...I figured I would be able to type of forumula in the value field for the textbox, but it treats it as text. Please help.

Delete Log Files Past A Certain Date
I have an application that I wrote that logs everything that the user is doing and trapps application errors. What I want to do is run a check before adding lines to the code that would look something like this...

if the folder holding the logs >= a specified size then
delete all files in folder older than 3 days,

or something that would set a certain log folder size limit and whenever that limit gets hit it deletes the oldest file in the folder to accomidate for the new ones. Anyone have any ideas how i could make a sub/function to do this by passing only the folder location? Code samples? Thanks

Find Date Of Monday Just Past
Hi All

I found a few threads here that were slightly similar but didn't properly understand them, so any help appreciated.

I need to find the date of the monday of the current week, so if its any day this week (including sunday 19th or monday13th) the returned date is 13/08/07

thanks all

When I Open Workbook Worksheet Is Named Today's Date Question
Workbook is opened (excel) worksheet is sheet (date$).select it works fine but if I close it on the same date it debugs. How can I tell it to check if there is sheet named by today's date and if their is one already named that way it will open it and begin work in "A17". If there isn't one open named by today's date it will make one and select "A17".

VBA excel


Changing Date From Today In Monthview Not Taking Place In Listview

I am here revisiting my one and only learning curve first VB6 project - A loan Amortization program. I have researched your forum for the solution but have not found it so I will present it to you.

The starting date for this project is always Today.

The attached snapshot will demonstrate that when I click on the date Sept 30, 2005 twice the MSFlexGrid is updated to show this date but I can't get the Listview to update to the changed date.

How can I accomplish this change to occur when a new starting date (Month Day Year) is selected in the Monthview???

Here is the code for the listview, but I can't get it to display the double clicked new date from the Monthview:

If NXtraPeriod = Val(gridHOSR.TextMatrix(gridHOSR.Rows - 1, gridHOSR.Cols - 10)) Then TxtExtra = 0
Dim dNumberPeriods As Long
Dim dOuterIndex As Long
Dim dCalendar() As Date
Dim intMonth As Integer
Dim intDay As Integer
Dim intYear As Integer
Dim ExtraPrincipal As Double
Dim d As Date
Term = Val(TxtTerm.Text)
Periods = Val(TxtPeriods.Text)
intDay = Calendar.Day
intMonth = Calendar.Month
intYear = Calendar.Year
Dim Dateclicked As Date
Calendar = intMonth & "/" & intDay & "/" & Right(intYear, 4)
d = Calendar
intMonth = 0
Max = Val(TxtTerm.Text) * Val(TxtPeriods.Text)
dNumberPeriods = Max
Calendar = d
d = DateAdd("m", -1, d)
CVDate (Format(CStr(Dateclicked), "dd mmm yyyy"))
For dOuterIndex = 1 To dNumberPeriods 'dNumberPeriods

intMonth = intMonth + 1
d = DateAdd("m", 1, d)
Set lItem = LVHOSR.ListItems.Add(, , intMonth)
lItem.ListSubItems.Add , , d
Next dOuterIndex

Select/copy/paste Cells Based On Today's Date
Thank you in advance to anyone who can pass on the gift of their script to me on this one. i work in a firm full of IT developers & support, admittedly whose expertise isn't in VB, but nonetheless you'd of thought one of them could answer this one.

I have a long macro already recorded in excel. in Column A of a particular worksheet is every work day from today to end 2009. Based on formulas contained in each corresponding cell B,C,D & F, values appear if today's date = the date in column A. I want to tell the macro at the very last step, to copy/"paste values" these cells based on selecting only cells B,C,D & F in row = today.

at the moment, 4-Mar-08 is in cell A 130 & the macro will continue, tomorrow to only copy/paste B130,C130,D130,F130 even though the values will be generated in row 131 tomorrow. the data input worksheet changes daily which is why i need to 'lock in' these end of day values with a copy/'paste values' finish to each day.

Hoping someone out there can help me.

Thanks a lot to that person,

Grace Period Past Expire Date
need help creating code for grace period. I have licenses that expire the last day of the month in a specified year(yyyy), and trying to start code on how to extend the grace period of 30 days past the due date (last day of ea. month) that they come due.

Hey guy! I have an update query that will check for null values in my table. I know it works cause I already imported one table, but when I Imported the second table it doesn't let me update the table cause it says that I have a key violation, lock violation or validation rule violation. I already check for this violation and I don't have any of them. I check the conversion fields and they are alright. I check the datafileds and they are right.


How To Know The Date In &lt;x&gt; Days?
Is there a way with VB to know the date in <x> days?
Ex: What will be the date in 25 days? (day/month/year)

Add Days To A Date
I have an application which the current date is displayed. I need to add 21 days to that current date. How is this done?


I Want The Date Of Some Days Ago...
Hi all.
i need something that give me the date of 5 days ago or 1 week...
there is some function like Datediff known for do this automatically?

now is 10/2/2003
i want another date automatically calculated 5/2/2003

thnk you all!!!!

Date {add Days To}
hi i was wondering if any1 can help me with this as i had many attempts my self

i have a txt box called txtdate = the user inputs any date i.e 04/03/05
i then have another txt box called txtdays = user inputs no. of. days the book is rented out for
finally i have a box called txtreturn = this box displays when the books is due back after da cmdcalculate button is clicked on.

basically the user inputs a date in2 txtdate and a number in txtdays, user then clicks on cmdcalculate n the retturn date is shown in txtreturn.

can any1 help me with this thanks

How Can I Now What Was The Date B4 44 Days
i have the today date =10/14/02 and i want to know what was the date before say 44 days is there any function that could help me?


30 Days After A Given Date?
how can i make a textbox with a date eg. 8/11/02 tell me if it is 30 days after that date using the computers clock?

any suggestions?

How Do I Add 7 Days To A Date?
Hello. I'm writing a program to simplify my business. Basically, you choose what you want to send-
1)letter to prospect concerning their resume
2)letter to prospect telling them when training meeting is
3)letter to prospect confirming their reservation
4)letter to city leader confirming prospect's reservation

Everything is pretty automatic, and for good reason. When this is finished, I'm distributing it to all representatives in the company.

I have them enter the meeting date as follows:
month (MM) in txtMeeting1
day (DD) in txtMeeting2
year (YY) in txtMeeting3

Then, it prints the date of the meeting in the letter to the prospect/city leader, plus the date of next week's meeting. I don't know how to accomplish the latter. Could someone please help me out? How do I take the date I enter and make another date that's exactly 7 days after that? I'm totally lost


How To Add Days In A Date?
i have begindate.text and enddate.text

begindate.text = 05/02/06
enddate.text = 180 'days

sample output is: 10/29/06

what function should i used to comeup with the output.

thanks in advance...

Date Plus X Days
I would like to add x number of days to today or a variable date, can you advise on the best way of acheiving this

Many Thanks


How To Add Days To A Date

I have a project in which the user chooses the number of days they wish to hire an instrument. On the receipt form i would like the date the intrument is to be returned to be displayed. However, i do not know the code to have the computer add X number of days to the date of hire.

Any help would be greatly appreciated.


How To Add Days In Date??

I have table in access2000 having field date. I want to add days in existing date and want to get new date. How to do this???

Pratik mehta

Add Days To Date
Hi Codeguru friends,

I´m a prommager from Chile. I would like to know if you have some code that add days to one date..something like this :

fin.Text = 21/5/2001 + 30 ' Days
fin.Text = 21/5/2001 + 90 ' Days
fin.Text = 21/5/2001 + 180 ' Days
fin.Text = 21/5/2001 + 360 ' Days

But I lost it, Could you help me please ?
It looks something like this:

"fin.Text = CStr(START.Text + Text1.Text) ?"
"fin.Text = CCur(START.Text) + CCur(Text1.Text) ?"

It was a good code for the job I want to do.

I hope you can help me.

Best Regads,


How To Check Date If Its Weekend Date?
hi all
how to check if any date falls on weekend?


Copyright © 2005-08, All rights reserved