473,326 Members | 2,108 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,326 software developers and data experts.

Convert DateTime to seconds

13
Hi,

I have some date time in xml file:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <ProductionPerformance>
  3.     <ActualStartTime>2008-12-07T01:00:00</ActualStartTime>
  4.     <ActualEndTime>2008-12-09T01:00:00</ActualEndTime>
  5. </ProductionPerformance>
  6.  
where I need to convert ActualStratTime to seconds in xsl:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <xsl:stylesheet version="1.0" 
  4.     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  5.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  6.     xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
  7.  
  8.  
  9. <xsl:include href="date/functions/date-time/date.msxsl.xsl"/>
  10.  
  11. <xsl:template match="/ProductionPerformance">
  12. <item>
  13.     <xsl:variable name="mydatetime" select="'2009-02-27T15:34:01'"/>
  14.     <xsl:value-of select="date:seconds($mydatetime)"/>
  15. </item>
  16. <item>
  17.     <xsl:value-of select="./ActualStartTime"/>
  18. </item>
  19. <item>
  20.     <xsl:variable name="myseconds" select="./ActualStartTime"/>
  21.     <xsl:value-of select="date:seconds($myseconds)"/>
  22. </item>
  23. </xsl:template>
  24. </xsl:stylesheet>
  25.  
I use date:seconds function to convert the ActualStartTime. It works in the first item when I write '2009-02-27T15:34:01'´as input for the function. However, it does not works anymore when I try to get data from item ./ActualStartTime from the first xml file. I got an error: "Microsoft JScript runtime error Wrong number of arguments or invalid property assignment line = 953, col = 3 (line is offset...
". It seems that it can not get the input.

Could someone help?
Regards
maxin
Feb 27 '09 #1
2 6229
jkmyoung
2,057 Expert 2GB
Try
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="myseconds">
  2.   <xsl:value-of select="./ActualStartTime"/> 
  3. </xsl:variable>
  4.  
The difference? $myseconds is now a String instead of an XMLNodeList.
Feb 28 '09 #2
maxin
13
Hi,
Thanks for your answer. However, I get the same error as before.
Regards
maxin
Mar 1 '09 #3

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

Similar topics

1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
2
by: Rudi Groenewald | last post by:
Hi all. If I've got a query which has a field with seconds in it... how will I use the Convert function to get my field converted to the format: HH:MM:SS ? The field with the seconds in is...
15
by: JenHu | last post by:
Hi expert, I have a data field (birthdate) contains a datetime datatype (mm/dd/yyyy), how can I convert to mmdd?? say, the birthday is 8/1/1979 and convert to mmdd DOB =...
6
by: Mike | last post by:
I'm getting my data from my database in seconds, 3600, how can i convert that to time such as 1:00 pm?
10
by: Philip Wagenaar | last post by:
I have some code to convert a date to the unixdatetime representation (number of seconds since 1970). Only problem is that it only counts from the whole day, it ignores the times part. So convert...
1
by: Ryan Ramsey | last post by:
I am trying to convert a value returned from the date() function in php 5.0 to a format .NET can use. DateTime dt_now = DateTime.Now; DateTime dt_last = new DateTime(Convert.ToInt32(dkpLast));...
6
by: Carl J. Van Arsdall | last post by:
Basically I used the datetime module and timedelta objects to calculate a difference between two times. Now I'm trying to figure out how I make that time delta a string HH:MM:SS to show elapsed...
3
by: Aggelos | last post by:
I suppose that has been discussed. I search on google but couldn't find a short answer. I have a datetime field: 2006-10-10 12:00:00 And I want to get that in seconds. Should I break the date and...
5
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have about ten integer values that each need to be converted to days, hours, minutes and seconds. I can't seem to find a formula for same that works. These integer values come from a...
3
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have various times formatted like 00:00:00, so for example, 01:32:05 would be one thirty-two with five milliseconds. I need to convert this into seconds (an integer). First of...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.