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

The best date store & calculation

DateTime.UtcNow is added as root attribute, 'Modified' of an xml whenever
xml is changed.
Every 5 secs a check is made whether xml is changed or not, by comparing
previous 'Modified' and current 'Modified'.

By considering performance in mind whats best to way of stroring and
calculating date in this case?

Is UtcNow best for comparing every 5 secs.?
Or is it better saving UtcNow.ticks and comparing it.?

How to get UtcNow.ticks in seconds/milliseconds?
UtcNow.ticks gives ticks from Jan 01, 0001. How to get it from another date,
say How to get ticks/milliseconds since jan 01, 1970 (as in case of
Javascript)?
thanks,
Praveen
Jul 13 '07 #1
2 1799
>From the computer's perspective, "every 5 seconds" is not very often,
so I would keep it simple and stick with the natural format, DateTime.
Less to go wrong.

For duration between 2 times, use Subtract, which gives you a
TimeSpan. Or simply subtact pre-caculate the ticks of your origin
date, and subtract this from the ticks for now - i.e. (notepad code -
not tested)
long origin = new DateTime(1970,1,1).Ticks; // note this is in local
time, not UTC
....
long ticks = DateTime.Now.Ticks - origin; // so use local time here
also?

Can I ask what the scenario is here? What could change the xml? It is
a file? Something in memory? There may be other ways to monitor for
changes. Size of the xml, and the source (remote database vs in local
memory) makes a difference too.

Marc

Jul 13 '07 #2
OK - more or less what I suspected; just watch out for thread safety
when accessing the various objects. Web apps are multi-threaded.

Marc
Jul 13 '07 #3

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

Similar topics

3
by: rhaley | last post by:
ugh. Okay, I need to figure out the number of milliseconds between DateTime.Now and the end of the day so that I can make changes based on the date roll-over. I need to implement a Timer so that I...
4
by: William Bradley | last post by:
I have two cells on a form. One of them is the "Production Date" and the other is the "Expiry Date". The "Expiry Date" is 183 days after the "Production Date." On an Excel spreadsheet, the...
16
by: PeteCresswell | last post by:
I was happily coding along, putting some calculation results (rolling annualized rates of return - too compute-intensive to calculate on-the-fly - had tb staged beforehand via a batch job) into...
1
by: John | last post by:
Hi I am using and access datetime field to store both date & time. How can I split it into date & time after reading the field and then combine the date & time back into datetime when storing...
2
by: Niyazi | last post by:
Hi everyone, I have a sql table that has 5 column as: cl1Month - cl1_3Month - cl3_6Month - cl6_12Month - clMoreThan12Month Now I have to date and I have to find the differences and check as...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
1
by: jonny | last post by:
Option Explicit Private mdTarget1 As Date Private mdTarget2 As Date ' called on form load Public Sub SetRecordStartTime() mdTarget1 = DateAdd("n", 60, Time) mdTarget2 = DateAdd("n", 120,...
4
by: tuananh87vn | last post by:
hi, I have some problems related to date type: In mysql, I created a table with some fields of date type, so how can I use php to insert date value in into database (then db will store date format,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.