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

Dates - XLS Formatting string based on another element value

108 100+
Greetings,

I have a string element called DeliveryDateTime which stores the date/time as dd/mm/yy hh:mm.

I wish to change the hour value based on the value of another string field called "timezone" which holds values as GMT+1, GMT+2 and GMT+3

I know the hour value, hh will always be in positions 10,11 so could use some kind of substring command.

I could perhaps us <xs-If> to check the value of TimeZone but unsure how to manipulate the strings to change their value.

I also know the numeric value in timezone is always in postion 5.

Does anyone have any ideas how to resolve this?

In pseudo code I can only think of an extreme number of if/then to resolve the issue.

Or perhaps I should think about changing DeliveryDateTime and Timezone into type like integers I could work with easier??

I couldt get my head around the timezone element to help me resolve this issue.

Can anyone guide me?
Cheers
Rob
Nov 7 '07 #1
2 1441
jkmyoung
2,057 Expert 2GB
I agree with changing the values into integers temporarily.
Pseudocode:
-Get the number after string GMT. say $shift. select="substring-after(timezone, 'GMT')"
-Get the hour value, say $hour: select="substring(DeliveryDateTime, 10, 2)"
-Add or subtract it to the current hour, add 24, and take the mod of the number 24
($hour - $shift + 24) mod 24

The reason we add 24 to begin with is so we don't end up with a negative number. Even if $hour - $shift is already > 0, we cancel it out with the mod 24.
Nov 7 '07 #2
robtyketto
108 100+
Well Ive decided to look at this and investigate more.

I need to read more about variables and elements but heres some psuedo code(well mixture of pseudo code and xsl code)

<xsl:for-each select="//my:POD/my:Customer">
<xsl:choose>
<xsl:when test ="@xsi:type='NonUKCustomer'">

<xsl:variable name="hour" as="xs:integer(substring(my:PODBatch/my:POD/my:DeliveryInfo/my:DeliveryDateTime,10,2)"

<xsl:variable name ="seconds" as ="xs:integer(substring(my:PODBatch/my:POD/my:DeliveryInfo/my:DeliveryDateTime,12,3)"

<xsl:variable name="hourdifference" as="xs:integer(substring-after(my:PODBatch/my:POD/my:Customer/my:Timezone,’GMT+’)"

<xsl:Variable name=newhour" as="xs:integer(hour + hourdifference + 24) mod 24./>

<xsl:Variable name "newtime" = newhour + seconds = correct time./>

</xsl:when>
</xsl:choose>


I just need to change it into working code!!!

Thanks
Rob
Nov 15 '07 #3

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

Similar topics

7
by: smcgouga | last post by:
Visual Basic 6. ADO 2.8 I have an as400 DB2 V5R1 datasource. Dates are defined as *ISO format and have a range from '0001-01-01' to '9999-12-31'. I am trying to update a date field on the...
8
by: A.M | last post by:
Hi, Are string parameters in functions by refrence or by value ? Thanks, Ali
3
by: funkyMonkey | last post by:
I'm binding date fields from entity objects and formatting the output in the text box in short date format. Code: BindDateField(Me.txtCheckIn, "Text", reservation.BookingDetail, "CheckIn")...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
9
by: David Jackson | last post by:
Hello, Is there anything in the framework which will format a date to show the ordinal representation of the day value e.g. 28th June 2007 1st August 2007 instead of
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
4
by: Michael Sharman | last post by:
Hi guys, I'm a little confused with dates. Ok, all I want to do is store a date in MySQL as a datetime object and be able to read and format it using PHP. My datatype in MySQL is DATETIME and...
27
by: rhaazy | last post by:
I need to write some javascript that will return a date string in the form mm/dd/yyyy. The date needs to be today's date - 30 days. Is there a relatively straight forward way to do this? So...
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:
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
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
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.