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

Jscript date

Hi,

I get two dates in the format 27/07/2006 from two fields (checkindate,chackoutdate) and I want to calculate the difference in days between them... Can you help?
Nov 8 '06 #1
13 2327
vee10
141 100+
Hi,

I think the following code solves ur problem
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5.  
  6. <html xmlns="http://www.w3.org/1999/xhtml" >
  7. <head runat="server">
  8.     <title>Untitled Page</title>
  9.     <script type="text/javascript">
  10.     function find()
  11.     {
  12.     var string=document.form1.Start.value;
  13.     var string1=document.form1.end.value;
  14.     var day=string.substring(0,2);
  15.     var month=string.substring(3,5);
  16.     var year=string.substring(6,string.length);
  17.     var day1=string1.substring(0,2);
  18.     var month1=string1.substring(3,5);
  19.     var year1=string1.substring(6,string.length);
  20.  
  21.   var startingdate=new Date(year,month-1,day); 
  22.   alert(startingdate);
  23. var finishingdate=new Date(year1,month1-1,day1); 
  24. alert(finishingdate);
  25. var one_day=1000*60*60*24 ;
  26. document.form1.result.value=
  27. Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day)); 
  28.     }
  29.  
  30.  
  31.     </script>
  32. </head>
  33. <body>
  34.     <form id="form1" runat="server">
  35.     <div>
  36.          <input type="text" name="Start" />
  37.     <input type="text" name="end" />
  38.     <input type="button" name="sub" value="Find No:of days" onclick="find()" />
  39.     <input type="text" name="result" />
  40.  
  41.     </div>
  42.     </form>
  43. </body>
  44. </html>
  45.  
  46.  
  47.  
  48.  








Hi,

I get two dates in the format 27/07/2006 from two fields (checkindate,chackoutdate) and I want to calculate the difference in days between them... Can you help?
Nov 8 '06 #2
I have made some modifications and the script resulted to the following
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type=text/javascript>
  2.     var string=^Check_In_Date^;
  3.     var string1=^Check_Out_Date^;
  4.     var day=string.substring(0,2);
  5.     var month=string.substring(3,5);
  6.     var year=string.substring(6,string.length);
  7.     var day1=string1.substring(0,2);
  8.     var month1=string1.substring(3,5);
  9.     var year1=string1.substring(6,string.length);  
  10.   var startingdate=new Date(year,month-1,day); 
  11.   alert(startingdate);
  12. var finishingdate=new Date(year1,month1-1,day1); 
  13. alert(finishingdate);
  14. var one_day=1000*60*60*24 ;
  15. var result=Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day)); 
  16. document.write(result);
  17. </SCRIPT>
  18.  
When i run it I get the following message..

Object does not support this property or method
Nov 8 '06 #3
vee10
141 100+
hi ,

what is that ^check_in_date^
if it is the textbox then give it as document.formname.check_in_date.value
ok


I have made some modifications and the script resulted to the following

<SCRIPT type=text/javascript>
var string=^Check_In_Date^;
var string1=^Check_Out_Date^;
var day=string.substring(0,2);
var month=string.substring(3,5);
var year=string.substring(6,string.length);
var day1=string1.substring(0,2);
var month1=string1.substring(3,5);
var year1=string1.substring(6,string.length);
var startingdate=new Date(year,month-1,day);
alert(startingdate);
var finishingdate=new Date(year1,month1-1,day1);
alert(finishingdate);
var one_day=1000*60*60*24 ;
var result=Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day));
document.write(result);
</SCRIPT>

When i run it I get the following message..

Object does not support this property or method
Nov 8 '06 #4
AricC
1,892 Expert 1GB
I have never seen ^ used that way.
Nov 8 '06 #5
It is used by foxrpro. It is an HTML document that is created from the database and ^Check_In_Date^ refers to a certain field.

Maybe I'm writing sth that may never work.
Nov 9 '06 #6
When the program executes and the page created this field is substituted by 27/07/2006
Nov 9 '06 #7
vee10
141 100+
hi,

is that program running or same error u r getting


When the program executes and the page created this field is substituted by 27/07/2006
Nov 9 '06 #8
No it is not.
Nov 9 '06 #9
iam_clint
1,208 Expert 1GB
Let me see All of your pages code please wrap it up with [ CODE] and [ /CODE] and we will get it figured out for you.
Nov 9 '06 #10
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type=text/javascript>
  2.     var string=^Check_In_Date^;
  3.     var string1=^Check_Out_Date^;
  4.     var day=string.substring(0,2);
  5.     var month=string.substring(3,5);
  6.     var year=string.substring(6,string.length);
  7.     var day1=string1.substring(0,2);
  8.     var month1=string1.substring(3,5);
  9.     var year1=string1.substring(6,string.length);  
  10.   var startingdate=new Date(year,month-1,day); 
  11.   alert(startingdate);
  12. var finishingdate=new Date(year1,month1-1,day1); 
  13. alert(finishingdate);
  14. var one_day=1000*60*60*24 ;
  15. var result=Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day)); 
  16. document.write(result);
  17. </SCRIPT>
Nov 10 '06 #11
vee10
141 100+
hi,

by writing ^Check_In_Date^ is the value is assigned to the string once place an alert box after string="^Check_In_Date^

alert(string)











Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type=text/javascript>
  2.     var string=^Check_In_Date^;
  3.     var string1=^Check_Out_Date^;
  4.     var day=string.substring(0,2);
  5.     var month=string.substring(3,5);
  6.     var year=string.substring(6,string.length);
  7.     var day1=string1.substring(0,2);
  8.     var month1=string1.substring(3,5);
  9.     var year1=string1.substring(6,string.length);  
  10.   var startingdate=new Date(year,month-1,day); 
  11.   alert(startingdate);
  12. var finishingdate=new Date(year1,month1-1,day1); 
  13. alert(finishingdate);
  14. var one_day=1000*60*60*24 ;
  15. var result=Math.floor((finishingdate.getTime()-startingdate.getTime())/(one_day)); 
  16. document.write(result);
  17. </SCRIPT>
Nov 10 '06 #12
Can you explain? I did not understand
Nov 10 '06 #13
vee10
141 100+
hi,

place the code so that u check it

var string=^Check_IN_Date^;
alert(string)












Can you explain? I did not understand
Nov 13 '06 #14

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

Similar topics

4
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. ...
14
by: John Bentley | last post by:
Note this is crossposted to comp.lang.javacript and microsoft.public.dotnet.scripting. After some Googling and FAQing my understanding of these terms is, crudely: Javascript (3 different...
6
by: Jim H | last post by:
I have an app I working on that was working fine a few days ago. Now I get a jscript error: Microsoft JScript runtime error: Object expected in a part of the code that has not been modifed or...
1
by: TdJ | last post by:
Hi guys, I am trying to build a dialog box that does the same as an "alert" but with out the exclamation mark graphic (which is causing some users to think something has gone wrong !? I have...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
2
by: Alex Nitulescu | last post by:
Hi. I have a header implemented as a user control (ascx). On start-up, I show the date/time (in a label named "lblTimer") like this: <html> ....... <span.... <%=Now.ToShortDateString() %> -...
1
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>...
2
by: Jer425 | last post by:
Hello, I'm coding in VB and trying to include a jscript file. This will not work because you can only use one language in asp.net. Is there a way that I can use the jscript without having to...
1
by: finditajr | last post by:
Hello I'm having the following problem: My main webpage calls a function stored in a .js file that creates an HTML window to display a calendar. Whenever I click on a date in that calendar,...
8
by: Arhaus | last post by:
I was wondering if someone could help me out. I am new to jscript and I need to modify a calendar onclick event. We have a calendar which displays the dates either in green or red based upon data...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.