473,804 Members | 3,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datediff

Hi.
I have 3 seperate date fields.

InitialDate
InspDate
ReportDate

I am trying to setup several unbound Text boxes in a form that will give me
days elapsed between these dates. These text boxes act like message boards
to alert the user if the days elapsed have exceeded a certain amount of
days.

Eg1. User populates the InitialDate field with a date. The InspDate and
ReportDate fields are for the moment left empty.
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate
field and current date), the message "INSPECTION OVERDUE" comes up and the
days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days
criteria.

The same goes for the populating of the InspDate field and leaving the
ReportDate field empty. A message in another unbound text box shows if over
6 days have elapsed from when the InspDate has been populated and the
current date.

Any help would be appreciated.

Nov 13 '05 #1
3 3355
Hi T23Ij9 (Nice name ..)
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate
field and current date), the message "INSPECTION OVERDUE" comes up and the
days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days
criteria.


I would use two lable controls say LblDaysPassed and LblMessage. For both caption = " "
Then I would use the forms Current-Event to change the caption.

Private Sub Form_Current()
Dim intDaysPassed as Integer
intDaysPassed=D ateDiff("d",[InitialDate],Date())
If IsNull(Me!InspD ate) then
Me!LblDaysPasse d.caption = intDaysPassed
If intDaysPassed >=6 then
Me!LblMessage.c aption = "INSPECTION OVERDUE"
Else
Me!LblMessage.c aption=""
End if
Else
Me!LblMessage.c aption=""
Me!LblDaysPasse d.caption = ""
End if
End Sub

Similar for your other ReportDate

--
Hope this helps
Arno R
Nov 13 '05 #2
Under caption in each label i entered ""
I placed the code in the form's current event but then i got a Run time
error '2465'
The error message said that it could not find the field "I" referred to in
the expression.

The expression it was referring to in the debugger was:

intDaysPassed = DateDiff("d", [InitialDate], Date)

For some reason the () in the Currnet Date part is not there ... should
originally read Date()
My question is - what expression do I use in the controlsource line of a
newly created unbound text box (which simply acts as a message board) to
show that when OVER 6 days have elapsed (between the date in the InitialDate field and current date), the message "INSPECTION OVERDUE" comes up and the days that have elapsed so far (would show up along side the message).
When the user populates the InspDate, this message in the unbound text box
and the days elapsed will then disappear.

I have tried the Datediff one:
=DateDiff("d",[InitialDate],Date()) but can't incorporate the Over 6 days criteria.


I would use two lable controls say LblDaysPassed and LblMessage. For both
caption = " "
Then I would use the forms Current-Event to change the caption.

Private Sub Form_Current()
Dim intDaysPassed as Integer
intDaysPassed=D ateDiff("d",[InitialDate],Date())
If IsNull(Me!InspD ate) then
Me!LblDaysPasse d.caption = intDaysPassed
If intDaysPassed >=6 then
Me!LblMessage.c aption = "INSPECTION OVERDUE"
Else
Me!LblMessage.c aption=""
End if
Else
Me!LblMessage.c aption=""
Me!LblDaysPasse d.caption = ""
End if
End Sub

Similar for your other ReportDate

--
Hope this helps
Arno R
Nov 13 '05 #3
> Under caption in each label i entered ""

Are your lable controls there ? When I enter "" as a caption my lable is gone ...
Change the caption to "x" and try again please.
For some reason the () in the Currnet Date part is not there ... should
originally read Date()

intDaysPAssed = DateDiff("d", [InitialDate], Date) should work.

Hope this helps
Arno R
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4106
by: CJM | last post by:
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to show links that are created/modified from that date minus 30mins to the present... eg effectively new and modified files: If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < 30 Then.... etc On my test machine this mechanism works OK, but on the live server (Win2k, IIS5) I get some...
8
5931
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 --------->could i get 2 years and 2 months and 1
6
16521
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days between values in the database and the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF command." Heh! Well, the user interface I'm using didn't even recognise DATEDIFF as being a function, so I decided to visit the mySQL...
1
8009
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days until completion: DateDiff("d",,) is TODAY the appropriate syntax for today's date? Could the function/expression even be set up that way, or do I need to do something else to get 'days until completion'? (My Access manuals do not mention a TODAY...
4
11920
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS STARTINGDATE1 ENDINGDATE1 STARTINGDATE2
1
4985
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
7
15509
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using DateDiff in VB.NET which is only available in C# if you don't mind linking in Microsoft.VisualBasic.dll to your C# application. I wanted to avoid this so set about a pure C# solution which uses a combination of TimeSpan in whole days and the...
5
7241
by: sr | last post by:
Anyone know of a better way to simulate a datediff for C#, i.e., without referencing the VB.NET runtime? Only added the functionality that was needed for me so it is not the full implementation of the DateDiff in the VB.NET runtime. private int DateDiff( string Interval, DateTime Date1, DateTime Date2 ) { int intDateDiff = 0; TimeSpan time = Date1 - Date2;
6
7651
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
2782
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error like datediff(mm,date1,date2) datediff(mmm,date1,date2) datediff(month,date1,date2) datediff("mm",date1,date2) datediff("mmm",date1,date2) datediff("month",date1,date2)
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.