datetime

C++ Converting a Datetime String to Epoch Cleanly

Is there a C/C++/STL/Boost clean method to convert a date time string to epoch time (in seconds)? yyyy:mm:dd hh:mm:ss ...

Datetime issue in Django

I am trying to add the datetime object of a person. Whenever the birth year is less than year 1942, I get a strange error DataError: unable to parse time when reading the data back from the DB. class Person(models.Model): """A simple class to hold the person info """ name = models.CharField(max_length=100) born = models....

Two dates within a year of each other

I got two dates, how do I check if both dates does not exceed over one year? Short question! :-) ...

linq group by a start time to endtime on DateTime Column

Ok this is kinda a messy query and I am only having limited success with it. I have a list of a Foo class that has a datetime property and other data. I have a class/row for allmost every minute, with some missing and some entire days missing like a holiday or weekend. My goal is to group each day for all rows from a start time to an ...

Crystal Reports Date functions

I'm trying to select only the records in which their date falls from the current date to the end of the month three months from now. Currently there are two dates in the table that match the query: Judy: 5/17/09 asdf: 8/9/09 This is my formula: DateVar current = Date(DurrentDateTime); //takes the time off DateVar ThreeMonthsAway = Dat...

How can I perform divison on a datetime.timedelta in python?

I'd like to be able to do the following: num_intervals = (cur_date - previous_date) / interval_length or print (datetime.now() - (datetime.now() - timedelta(days=5))) / timedelta(hours=12) # won't run, would like it to print '10' but the division operation is unsupported on timedeltas. Is there a way that I can implement div...

Sharepoint Calculated column formula for date-time comparison

Hi, I have two columns C1 and C2, both of type date and time in a document library. Now i want to create a calculated column C3 using which i could know which column(C1 or C2) is having greater value. I tried following formula for calculated column IF(C1>C2, 1,0) it works perfectly fine, but if i replace C1 with 'Modified' column it doe...

Ordinal Date Format C#

Problem: You are given dates in a format of YYYYddd, which is the year, followed by the day of the year, 1 through 365(366). For example today would be 2009135 (5/15/2009). What is the best way to create a new datetime from this? In Ruby I know there is a constructor that takes two numbers like so Date.ordinal(2009, 135) Is there a ...

How to select only Date value No Time in LINQ to SQL?

I need to have a query which list all the user according to the date value in the database. Problems is this, in the database the date format is 5/5/2009 4:30:12 but I want to compare with 5/5/2009. I think the value of the based date is 5/5/2009 12:00:00 and that's why I couldn't query it. The query is something like dim db = new dat...

How to convert date in Text box to MySQL DATETIME format

Hi, I'm quite new to php and have been reading Larry Ullman book to develop a basic db site. I have used the YUI Calendar pop up date picker to add a date to a text field called"date". The date format it enters is eg Thursday, 7 May 2009 I have tried many different ways to try and enter the date in to mysql db but it remains at 00 00 00...

What is the (best) way to handle dates before Christ in C#/.NET?

Is there any built-in support for that? And if not, is there any consensus about handling such dates? Links to owncoded solutions, or fragments of it, are very welcome. ...

Validate DateTime String in SQL Server 2005

Hi, I require a SQL script to validate a VARCHAR field in a table in a SQL Server 2005 database that contains DateTime values, in the format DD/MM/YYYY, or NULL values. I would like to identify all invalid dates. Can anyone suggest a method? UPDATE The answer has to make use of T-SQL; for performance reasons, I can't make use of SQ...

Model formsets and Date fields.

I have a model formset on a model with a couple of date fields - which again is a DateTimeField in the model. But when it displays in the template, it is shown as a text field. How can I show it as a drop down box ? WFormSet = inlineformset_factory(UserProfile, W, can_delete=False,exclude=[<list of fields to be excluded>], extra=3) T...

Any good lightweight date/time picker for web with good UI ?

Few wishes, If it is jQuery based, best. If it focus easy UI then eye candy, better. If it is date and time picker both, good. Edit: I should have mentioned , I already looked most options available that I can found using google. Problem is not a single date+time picker is part of official jquery-ui project so some are for old jquer...

Problems formating a date

I am trying to write a function to format a date and time for me. I have an almost identical function which formats just a date. That function works fine. I just added some code to try and have it format the date with a time. It should return something like "May 18, 2009 9:50 PM" but I am getting this warning: Warning: mktime() expects ...

Determine user agent timezone offset without using javascript?

Is there a way to determine the timezone for a user agent without javasript? normally, i would execute this snippet of javascript: <script type="text/javascript" language="JavaScript"> var offset = new Date(); document.write('<input type="hidden" id="clientTzOffset" name="clientTzOffset" value="' + offset.getTimezoneOffset() + '"/>...

datetime.now() in Django application goes bad

Hi, I've had some problems with a Django application after I deployed it. I use a Apache + mod-wsgi on a ubuntu server. A while after I reboot the server the time goes foobar, it's wrong by around -10 hours. I made a Django view that looks like: def servertime(): return HttpResponse( datetime.now() ) and after I reboot the server an...

CodeReview: java Dates diff (in day resolution)

Hello folks, Please your opinion on the following code. I need to calculate the diff in days between 2 Date objects. It is assured that both Date objects are within the same TimeZone. public class DateUtils { public final static long DAY_TIME_IN_MILLIS = 24 * 60 * 60 * 1000; /** * Compare between 2 dates in day resolution. * * @r...

How to parse a RFC 2822 date/time into a Python datetime?

I have a date of the form specified by RFC 2822 -- say Fri, 15 May 2009 17:58:28 +0000, as a string. Is there a quick and/or standard way to get it as a datetime object in Python 2.5? I tried to produce a strptime format string, but the +0000 timezone specifier confuses the parser. ...

Specific Time Range Query in SQL Server

Hi All, I'm trying to query a specific range of time: i.e. 3/1/2009 - 3/31/2009 between 6AM-10PM each day Tues/Wed/Thurs only I've seen that you can get data for a particular range, but only for start to end and this is quite a bit more specific. I didn't see any SQL Server commands that would directly help me on this, so does an...