473,503 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datediff Problem

I am having some difficulties with the function Datediff! I am trying to calculate the number of days between two given date

E.G: Number days between 03-05-2004 and 05-05-2004 =

I am using the following piece of asp to extract dates from an XML document and work with them to create the above mentioned result, however I can't get it to work

Can someone please assist!

Thank

...::XML Exampl
<Project><ProjectID>1</ProjectID><Tasks><Task><TaskID>1</TaskID><Start></Start><Finish></Finish></Task><Task><TaskID>2</TaskID><Start></Start><Finish></Finish></Task></Tasks></Project

...:: AS
<
'Load XM
set xml = Server.CreateObject("Microsoft.XMLDOM"
xml.async = fals
xml.load(Server.MapPath("ProjectTEST.xml")

'Load XS
set xsl = Server.CreateObject("Microsoft.XMLDOM"
xsl.async = fals
xsl.load(Server.MapPath("GantChartView.xsl")

'Finds Start date in all Tasks in xml documen
Dim sNodes(200,100
Dim sDate(200,100
Dim sTime(200,100
Dim sMonth(200,100
Dim sDay(200,100
Dim fdw(200,100

node=-
var=-

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start"

for each oNode in oNode
node=node+
for i=0 to 9
sNodes(node,i) = oNode.tex
nex

' Write whole data and time for Start of task as seen in XML Documen

'Break up date into different variable
var=var+
for i=0 to 9
sTemp = sNodes( node,0
sDate( var,i ) = Mid( sTemp, 1, 10
sTime( var,i ) = Mid( sTemp, 13, 4
sMonth( var,i ) = Mid( sTemp, 6, 2
sDay( var,i ) = Mid( sTemp, 9, 2
next

response.write "sDay " & (sDay(var,0)) & "<br>
'End Break up dates into variable

'Converts dates to beginning of week (Sunday
today = DateValue(sDate(var,0))
var=var+
for i=0 to 9
firstday = today + 1 - weekday(today, 1
fdw (var,i) = firstday

nex
FirstDayWeek = fdw (var,0
response.Write(fdw(var,0)
response.write(DateDiff("D", sDate(var,0), fdw(var,0))
next
Jul 19 '05 #1
1 1834
In my country 2 is correct. Check the Format or the LCID

"Tim::." <an*******@discussions.microsoft.com> schreef in bericht
news:BA**********************************@microsof t.com...
I am having some difficulties with the function Datediff! I am trying to calculate the number of days between two given dates
E.G: Number days between 03-05-2004 and 05-05-2004 = 2

I am using the following piece of asp to extract dates from an XML document and work with them to create the above mentioned result, however I
can't get it to work.
Can someone please assist!

Thanks

..::XML Example
<Project><ProjectID>1</ProjectID><Tasks><Task><TaskID>1</TaskID><Start></Sta
rt><Finish></Finish></Task><Task><TaskID>2</TaskID><Start></Start><Finish></
Finish></Task></Tasks></Project>

..:: ASP
<%
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("ProjectTEST.xml"))

'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("GantChartView.xsl"))

'Finds Start date in all Tasks in xml document
Dim sNodes(200,100)
Dim sDate(200,100)
Dim sTime(200,100)
Dim sMonth(200,100)
Dim sDay(200,100)
Dim fdw(200,100)
node=-1
var=-1

set oNodes=xml.selectNodes("/Project/Tasks/Task/Start")

for each oNode in oNodes
node=node+1
for i=0 to 99
sNodes(node,i) = oNode.text
next

' Write whole data and time for Start of task as seen in XML Document

'Break up date into different variables
var=var+1
for i=0 to 99
sTemp = sNodes( node,0 )
sDate( var,i ) = Mid( sTemp, 1, 10 )
sTime( var,i ) = Mid( sTemp, 13, 4 )
sMonth( var,i ) = Mid( sTemp, 6, 2 )
sDay( var,i ) = Mid( sTemp, 9, 2 )
next

response.write "sDay " & (sDay(var,0)) & "<br>"
'End Break up dates into variables
'Converts dates to beginning of week (Sunday)
today = DateValue(sDate(var,0))
var=var+1
for i=0 to 99
firstday = today + 1 - weekday(today, 1)
fdw (var,i) = firstday

next
FirstDayWeek = fdw (var,0)
response.Write(fdw(var,0))
response.write(DateDiff("D", sDate(var,0), fdw(var,0)) )
next

Jul 19 '05 #2

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

Similar topics

2
7135
by: News Central | last post by:
To all! I use the DateDiff function using VB6 and get this error 'Wrong number of argument or invalid property assignment' ... have anyone seen this problem? thanks ....
4
4080
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...
8
5917
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 ...
6
16499
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...
4
11904
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...
3
1920
by: chanchito_cojones | last post by:
i have a question regarding the DateDiff function. I am quite new to access and seem to have hit a snag with this function. My problem is as follows: I have a table field that list a persons...
1
2005
by: John T. | last post by:
I have two date fields: InitialDate InspDate I've tried to use a Datediff expression within an IIF function (see below) in an unbound textbox to give me the amount of days elapsed between...
7
15467
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...
6
7635
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?
12
2167
by: TofuTheGreat | last post by:
I did a group search and found hundreds of cases of problems with DateDiff(). I read through several dozen but they didn not apply to my situation. Not having the time to read through all of them...
0
7205
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
7093
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...
1
7011
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
7468
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
5596
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,...
0
3180
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
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...

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.