datetime

c# String to datetime

DateTime frm_datestart = DateTime.Parse(dateStart.Text); This line throws the error: Exception Details: System.FormatException: String was not recognized as a valid DateTime. Where the entered string is from Jquery-UI, examples: 09/29/2010 09/30/2010 Anyone know what the correct format should be? I'm suprised this isn't...

django order by date in datetime / extract date from datetime

I have a model with a datetime field and I want to show the most viewed entries for the day today. I thought I might try something like dt_published__date to extract the date from the datetime field but obviously it didn't work. popular = Entry.objects.filter(type='A', is_public=True).order_by('-dt_published__date', '-views', '-dt_writ...

How to convert time() to the format of 09/02/2010 in PHP?

$ts = time(); How to convert $ts to the format 09/02/2010 ? ...

Rails' datetime and timestamp in a migration file are the same for MySQL and Sqlite3?

:datetime and :timestamp in a migration file seems like the same in MySQL and Sqlite3, and they both map to datetime in the database side, except I can't find that in a formal documentation. Also, what about when if our Rails project may use other DBMS, then should we use :datetime or :timestamp when we script/generate (or rails generat...

Get the time of a datetime in TSQL?

Hello, how could I do this? I have a datetime in DB like this: 2010-09-06 17:07:28.170 What I want is only 17:07:28.170. Is there a function for that or something? Thanks :-) ...

How to set the default value of DateTime to empty string?

I have a property called Raised_Time, this property shows the time at which alarm is raised in datagrid Cell. I don't want to show anything in the datagrid cell when user creates any alarm, it just display the empty cell. I googled in the internet and found that the default value of DateTime can be set using DateTime.MinValue and this w...

how to shift a datetime object by 12 hours in python

Datetime objects hurt my head for some reason. I am writing to figure out how to shift a date time object by 12 hours. I also need to know how to figure out if two date time object's differ by say 1 minute or more. ...

Converting month name to integer

I did a quick search for this and was surprised not to find it anywhere. Basically looking to convert full month names (January, September, etc) to the equivalent number that would be used in mm/dd/yyyy format. I can put together my own array and pull it out accordingly, but there has to be a quick and straightforward method already. R...

Is this a good way of checking the amount of time it took to run some code in C#?

What I mean is... get the time, run the code, get the time, compare the time and get the seconds out: am I doing this right? DateTime timestamp = DateTime.Now; //...do the code... DateTime endstamp = DateTime.Now; string results = ((endstamp.ticks - timestamp.ticks)/10000000).ToString(); ...

C# DateTime.TryParse date year value swap. 30 Feb 02

Hi guys I have run into a datetime related problem, my program needs to varify whether a user entered date string is valid. The program is designed to process date value ranges from 01/01/2000 ~ 31/12/2020 and the string format is like "12 Feb 10". The problem I am facing is, sometimes user enters value like "30 Feb 10" (this value i...

Subdivide timestamps into 3 timeslots

I have following problem where I have to group different transactions into timeslots. Suppose you have a table with records which contain an entry datetimestamp. These records are created by users (operators) who work in different shifts Shift 1: 5 - 13h // Shift 2: 13 - 21h // Shift 3: 21 - 5h Now I want to have a flexible query whic...

Overlapping date range MySQL

Hi guys, I have the following data; ID startDate endDate ----------------------------------------------- 1 2010-03-01 10:00:00 2010-03-01 12:00:00 2 2010-03-01 12:30:00 2010-03-01 15:30:00 3 2010-03-01 15:30:00 2010-03-01 18:30:00 What I want to do is check that a start and end date don't fall inside ...

MySQL STR_TO_DATE gives invalid results?

I'm using MySQL 5.1.49 on Win64. We're seeing the following behaviour on Solaris machines as well. Here's my test table: CREATE TABLE `date_test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `date1` datetime NOT NULL, PRIMARY KEY (`id`), KEY `Index_2` (`date1`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; mysql>...

how to parse a time value of "400" (equivalent to 4:00) using DateTime.TryParseExact

I'm trying to convert user entered times into TimeSpans. Because TimeSpan does not have a TryParseExact method I'm using the one in DateTime and converting the output from it. The formats I want to handle are: 04:00, 0400, 4:00, and 400. The first three aren't a problem and correspond to the first three cases in the if/else structur...

How to sum 2 joda-time DateTime values (one containing a date and a zero time and another containing a time and a zero date)?

In a Scala 2.8 program of mine I use joda-time with its scala-time wrapper. I've got 2 DateTime values, one for a date (with zero time fields) and one for time (with zero date fields) (the reason of separation is a storage architecture). How do I get another DateTime value with both date and time parts set from a source pair? ...

Formatting Dates and DateTimes for User's timezone including Timezone Offset in C# (.net)

I am working on a C# application and want to display dates so they are local to the user's timezone. We have the user's timezone setting stored in the database, and all dates are stored in the database in UTC which should make this simple. The trick is that I also need to display the timezone offset for each date localized for the user.....

Perl Compare dates with MySQL

I'm struggling to figure out how to compare MySQL dates with current system time using perl. I have a script that runs on a cron job that will send notification if the current system date/time is past the date/time of a returned record: An application displays a table view: EventId Device Location CC: 123 something B...

jQuery datepicker date range throwing invalid date range error with valid dates

Hi, For some reason when i enter the following dates into the following fields it is returning an invalid date range and i am not sure why: http://jsfiddle.net/mQRaj/3/ To replicate please enter the following in the 'From' date: 30/11/2009 and then this in the 'To' date: 7/9/2010 Bur if i enter 16/11/2009 and 7/9/2010 it does not ...

'datetime.date' object has no attribute 'date'

This code: import datetime d_tomorrow = datetime.date.today() + datetime.timedelta(days=1) class Model(models.Model): ... timeout = models.DateTimeField(null=True, blank=True, default=d_tomorrow) ... resuls in this error: 'datetime.date' object has no attribute 'date' What am I doing wrong? ...

Separate date and time form fields in Rails

I have an ActiveRecord model Eventwith a datetime column starts_at. I would like to present a form, where date and time for starts_at are chosen separately (e.g. "23-10-2010" for date and "18:00" for time). These fields should be backed by the single column starts_at, and validations should preferably be against starts_at, too. I can of...