datetime

i get date in wrong format - need help

hi i get date from xml in this format: 7/16/2010 (mm/dd/yyyy) i have in my program datetime val - MyDate. and when i try to placing MyDate = Convert.ToDateTime(7/16/2010) i got error. how i can fix it ? thank's in advance ...

.NET DateTime, different resolution when converting to and from OADate?

I'm converting a DateTime to OADate. I was expecting to get the exact same DateTime when converting the OADate back, but now it has only millisecond resolution, and is therefore different. var a = DateTime.UtcNow; double oadate = a.ToOADate(); var b = DateTime.FromOADate(oadate); int compare = DateTime.Compare(a, b); //Compare is not ...

Parsing dates and times from string in many combinations

Hi. I need to parse dates and times from strings. The Problem is that the strings can have any possible format. But I also get the format strings. So i get: Date = "9/15/2010" Time = "16:12:45" DateFormat = "M/dd/yyyy" TimeFormat = "h:mm:ss" TimeZone = "+2:00:00" // +/- and time in TimeFormat But i have some problems parsing these ...

How to specify date format for model binding?

I hope the question is easy, but I am searching around for more than an hour and I just do not find the answer. So I have a asp.net mvc 2 application and one of the forms contains a date textbox with a jquery datepicker. I have set in the datepicker the date format to be dd.mm.yyyy. My problem is that on the model binding this date is in...

what determines .NET date formats in C# program?

I made a simple web service which worked nice with few systems that it was deployed. Now the date from Oracle causes trouble on other system. Some info: Our own methods that accesses oracle returns dates as string in format 15.09.2010 13:15:00 (note year in 4 digits) System working: -DateTime.ToSring() produces 16.09.10 14:15:49 (us...

How do I get locale day and month?

I'm using the following function to retrieve date and time: function formatEventTime($time, $type, $locale = 'nb_NO') { setlocale(LC_TIME, $locale); switch($type) { case 'date' : $format = '%d.%m'; break; case 'dm' : $format = '%d. %B'; break; case 'time' : $format = '%H...

Converting SQL number into a time, to perform date comparisons.

I am struggling with an SQL time comparison on two fields that have been set up as integers, rather than time stamps. I have some performance metrics in a database that the developer originally set up as int(8). The database contains the start and end times of a transaction. For example Some sample data may be id | start_time | end_ti...

DateTimeFormatInfo.CurrentInfo.LongTimePattern not updating

I am using this to read the current long time pattern in Windows: System.Globalization.DateTimeFormatInfo.CurrentInfo.LongTimePattern However, if I make a change in the regional settings in the Control Panel, this pattern isn't updated until I restart my application. How can I force this pattern to update when the regional settings ar...

Does ToLocalTime work between timezones?

The documentation says that... You can use the ToLocalTime method to restore a local date and time value that was converted to UTC by the ToUniversalTime or FromFileTimeUtc method. and goes on to say (immediately) However, if the original time represents an invalid time in the local time zone, it will not match the restored value....

Ruby, get hours, seconds and time from Date.day_fraction_to_time

I've found this method here. start = DateTime.now sleep 15 stop = DateTime.now #minutes puts ((stop-start) * 24 * 60).to_i hours,minutes,seconds,frac = Date.day_fraction_to_time(stop-start) I have the following error: `<main>': private method `day_fraction_to_time' called for Date:Class (NoMethodError) I've checked /us...

Read a DateTime object in a different time zone

I have following scenario: USA: database & application server Europe: client The server reads a date time (e.g. 12:00) object from the database and send it to a client in Europe. The problem is now, the client displays this date time in the time zone of the client (e.g. 18:00), but we need the time in the database, independent of the ...

Remove all but one duplicate rows where datetime column values are within seconds of each other?

Due to an error in the system a tracking log was firing repeatedly causing what should have been one log entry to actually be in the hundreds. This has been resolved but the data is still there and needs to be for reporting (I can't just deleted it all). However I only want ONE instance of the data. This is going to be tricky I think, he...

TimeZoneInfo.ConvertTime doesnt Covert anything

Running asp.net mvc 2 on win 7 with .net 4.0 I have a controller action method that receives 2 DateTime objects from a form. The UI on the form uses the jQueryUi datepicker (not sure if that maters). The user who fills out that form will ALWAYS be entering the date/time in Hawaiian time zone. I want to convert that to UTC time and ...

unit testing time format conversions

After ncovering an ugly bug I wouldn't have caught in winter, I've started to centralize conversions between different time formats. I've already found some bugs by comparing different conversion paths, but need something more systematic. Test goals are correct conversion on all paths (of course), and errors on rimes not represented cor...

How do I convert datetime to date (in python)?

Hi, the title says nearly all I want: How do I convert a datetime.datetime object (e.g. the return value of datetime.datetime.now()) to a datetime.date object in Python? ...

Mysql: Calculate visit frequency.

I have this table CREATE OR REPLACE TABLE hits (ip bigint, page VARCHAR(256), agent VARCHAR(1000), date datetime) and I want to calculate googlebot visit frequency for every page. ... WHERE agent like '%Googlebot%' group by page ...

Mysql: Calculate averge time between visits

This related to my other question. I have this table CREATE OR REPLACE TABLE hits (ip bigint, page VARCHAR(256), agent VARCHAR(1000), date datetime) and I want to calculate average time between googlebot visit for every page. ... WHERE agent like '%Googlebot%' group by page order by date Something ...

How does android store dates without year?

I have been working with a Birthday reminder application for quite some time. During which, I have noticed that contact birthdays are being stored in different formats on different devices. Several of them are given below. yyyy-MM-dd yyyy-MM-dd'T'HH:mm:ss'Z' yyyy-MM-dd'T'HH:mm:ss.SSS'Z' It took many crashes and bug-reports to figure ou...

Using a datetime as filename and parse the filename afterwards?

Hello, I am writing files to my harddrive,The filename is build like this: String.Format("{0:yyyy-MM-dd_hh-mm-ss}.txt", DateTime.Now) So the filename is "2010-09-20_09-47-04.txt" for example. Now I want to show those filenames in a dropdown, but with another format. The format should be dd.MM.yyyy HH:mm:ss. How can I do that, or is th...

How to present date as a string on matlab figure

Hello, I have imported date&time data from a text file, in which it was stored as a string, to Matlab. I can convert string to numeric data and back, by using datenum and datestr commands. My problem is with creating figures. I can easily plot data against numeric date&time values, but as it is stored as a number, it is not very useful...