473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Date Function in VB

hey guys,
I am trying to use a dateadd function when they put in a check in date let say 08/31/07
and today is 08/16/07 is suppose to prompt then the they are not within the 15 days to cancel there item

Expand|Select|Wrap|Line Numbers
  1. Dim Resv As Date
  2. ' this is the codes i have so far:
  3. Resv = (DateAdd("d", 15, txtitem.Text))
  4. If Not (Resv <= txtitem) Then
  5.   MsgBox "Sorry Cancellation is not within the 15 Days Cancellation Period", 
  6.   txtitem.SetFocus
  7.   Exit Sub
  8. End If
Any suggests.....
Aug 15 '07 #1
3 1397
kadghar
1,295 Expert 1GB
hey guys,
I am trying to use a dateadd function when they put in a check in date let say 08/31/07
and today is 08/16/07 is suppose to prompt then the they are not within the 15 days to cancel there item

Dim Resv As Date
this is the codes i have so far:
Resv = (DateAdd("d", 15, txtitem.Text))
If Not (Resv <= txtitem) Then
MsgBox "Sorry Cancellation is not within the 15 Days Cancellation Period",
txtitem.SetFocus
Exit Sub
End I

Any suggests.....
Hi,
First of all, i hope txitem is a date, I really dont feel like i understood you perfectly well, but i think that what we have is that a reservation must be done at least 15 days before the check in date.

Lets say that txtItem is where you write the check in date. so..

Expand|Select|Wrap|Line Numbers
  1. Dim Resv As Date
  2. Resv = (DateAdd("d", 15, txtitem.Text))
  3. 'now resv is 15 days before the check in date
  4. If Not (Resv <= Date) Then
  5. ' Here is where i think you were wrong, i used Date (that it's today's date)
  6. MsgBox "Sorry Cancellation is not within the 15 Days Cancellation Period", 
  7. txtitem.SetFocus
  8. Exit Sub
Hope this helps
Aug 15 '07 #2
Hi
I think what is happening is that you are tring to compare two strings and not a numeric value. Try using the Datevalue() function to convert your dates to a numeric value.

ie:
If Datevalue(txtItem.text) >= (Datevalue(txtItem.text) + 15) then

End if
Aug 15 '07 #3
Killer42
8,435 Expert 8TB
Yes, you need to be very careful comparing dates or other numeric values in strings - VB will do an alphabetic comparison, which probably won't achieve what you want.
Aug 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
8
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
1
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
10
by: John Morgan | last post by:
Does anyone know what parameter should be used instead of Date = 0 for the optional parameter in the following function? Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
3
by: dave | last post by:
I need to compute an expiration date based on the number of hours, days, or months purchased. The expiration date needs to be expressed in minutes something like '1260481600'. How can I get the...
10
by: Jes | last post by:
Dear all I have a date field on a HTML form where the user is asked to key in dd/mm/yyyy However, when that is written to MySql it is either not accepted or another value is tored in the...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.