473,320 Members | 1,794 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,320 software developers and data experts.

Compare Input Date to Server Date

Good Day -

I have a form which sets the current date, as follows:
<script type="text/javascript">
xx=new Date()
dd=xx.getDate()
mm=xx.getMonth()+1
yy=xx.getYear()
mmddyy=mm+"/"+dd+"/"+yy
document.write(mmddyy)
</script>

The same form has a text box where the user is asked to input a date (a
travel date) in the format mm/dd/yyyy.

What I would like to do is compare the user input date to the current date,
and if the user input date is less than 2 days in advance of the current
date, return an alert saying that the input date is not enough in advance of
the current date.

I checked Dr. Stockton's site
(http://www.merlyn.demon.co.uk/js-date1.htm#DC) but was unable to find such
a comparison.

Any help or suggestions would be appreciated.

Scott
Jul 20 '05 #1
2 10170
Lee
Scott Knapp said:
What I would like to do is compare the user input date to the current date,
and if the user input date is less than 2 days in advance of the current
date, return an alert saying that the input date is not enough in advance of
the current date.

I checked Dr. Stockton's site
(http://www.merlyn.demon.co.uk/js-date1.htm#DC) but was unable to find such
a comparison.

Any help or suggestions would be appreciated.


There is a link on that page labeled "Date Arithmetic".
Following it takes you to:
http://www.merlyn.demon.co.uk/js-date2.htm

Search that page for the section titled "Difference in Days"

Jul 20 '05 #2
JRS: In article <hu*****************@bignews4.bellsouth.net>, seen in
news:comp.lang.javascript, Scott Knapp <mc*@publinx.com> posted at Thu,
2 Oct 2003 11:28:47 :-
Good Day -

I have a form which sets the current date, as follows:
<script type="text/javascript">
xx=new Date()
dd=xx.getDate()
mm=xx.getMonth()+1
yy=xx.getYear()
mmddyy=mm+"/"+dd+"/"+yy
document.write(mmddyy)
</script>

The same form has a text box where the user is asked to input a date (a
travel date) in the format mm/dd/yyyy.

What I would like to do is compare the user input date to the current date,
and if the user input date is less than 2 days in advance of the current
date, return an alert saying that the input date is not enough in advance of
the current date.

I checked Dr. Stockton's site
(http://www.merlyn.demon.co.uk/js-date1.htm#DC) but was unable to find such
a comparison.


My site has more than one page on date/time in javascript. Comparison
is not subtraction; however, comparison can be used in this case. On the
World-Wide Web, ambiguous date formats should not be used; use YYYY/MM/DD.

alert( Math.round( ( new Date('2003/10/05') - // date from user
new Date().setHours(48) )/864e5)>0 ? 'OK' : 'Dud' )

Math.round allows for the possibility of a change in Summer Time state.

If you need 2 clear days, then replace 48 with 72.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 20 '05 #3

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

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
9
by: Rich | last post by:
Thanks for the Help in my previous post. I've been working on this and it's almost what I want. I want to obtain the user's current age by comparing their date of birth (user inputs) to the...
9
by: Rimuen | last post by:
Have two text form with dates i need to compare before submitting, the second should always be a date later the first one. Anyone have a script for this ?? Thanks.......
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
3
by: Peter | last post by:
ASP.NET 1.1, this is a Intranet application and runs only on IE. I have two webform text boxes which contain dates - starting date and ending date. The dates could be in any format. for...
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...
4
by: xiaowei | last post by:
I m writing some VB codes for my access database... Now I have a table which contains a "editDate" field, its format is "26/06/2007 11:12:34 AM", then I created a form which would ask the user to...
2
by: site | last post by:
Have to compare dates of two rows in one table Input table COL1| COL2| COL3| COL4 1| A| 1-Jan-07| 6-Feb-08 2| A| 7-Feb-08| 31-Mar-08 3| A| 1-Jan-09| NULL SQL code to compare COL 4 date (Row...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.