datetime

strptime() equivalent on Windows?

Is there a good equivalent implementation of strptime() available for Windows? Unfortunately, this POSIX function does not appear to be available. Open Group description of strptime - summary: it converts a text string such as "MM-DD-YYYY HH:MM:SS" into a tm struct, the opposite of strftime(). ...

Determine Whether Two Date Ranges Overlap

Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap? As an example, suppose we have ranges denoted by DateTime variables StartDate1 to EndDate1 and StartDate2 to EndDate2. ...

Convert wide character strings to boost dates

I need to convert several million dates stored as wide strings into boost dates The following code works. However, it generates a horrible compiler warning and does not seem efficient. Is there a better way? #include "boost/date_time/gregorian/gregorian.hpp" using namespace boost::gregorian; #include <string> using namespace std; ...

Change default date time format on a single database in SQL Server

I need to change the date format from US (mm/dd/YYYY) to UK (dd/mm/YYYY) on a single database on a SQL server machine. How can this be done? I've seen statements that do this for the whole system, and ones that do it for the session, but I can't change the code now as it will have to go through QA again, so I need a quick fix to change...

time.h drop-in replacement : time_t for values (year < 1970) and (year > 2038) in ANSI-C or C99

I have a piece of code in ANSI C which uses the time.h library and time_h structures to (amongst other date-related calculations) work out the interval between two given dates. This works fine but this limits my code to input between 1970 and 2038. I would now like to make my code more general. Is there a common C library (ANSI or C99 s...

php mysql date/time question

I've built a small application which has User Management, a frontend console to enter data and a backend console to control parts of the frontend. The frontend adds rows to a MySQL database which are timestamped. The backend needs to be able to select rows from the database between X and Y dates. Everything works so far, except the date...

Is there a more efficient way of creating a list of years/months?

On a page I want to dynamically list years and all the months in each year so an archive for each month can be viewed. I want to show the current year first but the current year may not be over yet so I only want to show the months that have passed, and the current month. Then I want all years and all months in the past since this year (...

How do I do a Date comparison in Javascript?

I would like to compare two dates in javascript. I have been doing some research, but all I can find is how to return the current date. I want to compare 2 separate dates, not related to today. How do I do that. var startDate = Date(document.form1.Textbox2); ...

Can You Determine Timezone from Request Variables?

Is there a way to do your timezone offsets on the server side, by reading something in the request over http, instead of sending everything to the client and letting it deal with it? ...

Can you round a .NET TimeSpan object?

Can you round a .NET TimeSpan object? I have a Timespan value of: 00:00:00.6193789 Is there a simple way to keep it a TimeSpan object but round it to something like 00:00:00.61 ? ...

How do I strptime from a pattern like this?

Hi, I need to use a datetime.strptime on the text which looks like follows. "Some Random text of undetermined length Jan 28, 1986" how do i do this? ...

How can I list the missing dates from an array of non-continuous dates in Java?

I have a table of data sorted by date, from which a user can select a set of data by supplying a start and end date. The data itself is non-continuous, in that I don't have data for weekends and public holidays. I would like to be able to list all the days that I don't have data for in the extracted dataset. Is there an easy way, in Ja...

Comparing dates in Lingo

How do I compare two dates in Lingo? To be specific, I want to know if today's date is after some fixed date. I know I can create the fixed date by using: date("20090101") and I can get the current date using: _system.date() but I can't seem to directly compare the two. Do I have to parse the _system.date() to determine if it's aft...

Getting the time zone as a UTC offset on windows and linux.

What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command? ...

Convert datetime in to date

How do I convert a datetime field in Grails to just date, with out capturing the time? I need to do this for comparison with system date. class Trip { String name String city Date startDate Date endDate String purpose String notes static constraints = { name(maxLength: 50, blank: false) st...

How to return a Date (not a TimeWithZone) from a Oracle date column in ActiveRecord?

Environment: Rails 2.2.2, Oracle 10g Most of the columns declared "date" in my ActiveRecord models are exactly that: dates: they don't care about time at all. So with a model declared thus:# class MyDateOnlyModel < ActiveRecord::Migration def self.up create_table :my_date_only_model do |t| t.date :effective_date t.ti...

MySql Null DateTime and MS.net are not playing nice.

Heres the issue. I have a table(mySQL) that contains dates and some of them are null. I know that I can use DateTime? or Nullable to allow nulls, but I'm not sure where to set it. What I've tried: I built the class in the dblm. The date propery has the following attributes set: Nullable : True Server Data Type : DateTime Type : NUll...

Convert SQL server datetime fields to compare date parts only, with indexed lookups

I've been doing a convert(varchar,datefield,112) on each date field that I'm using in 'between' queries in SQL server to ensure that I'm only accounting for dates and not missing any based on the time part of datetime fields. Now, I'm hearing that the converts aren't indexable and that there are better methods, in SQL Server 2005, to co...

SQL Server 2005 Date Time stamp Query

Hi Guys, One of my columns type is DateTime (Date Registered). I cannot create a query that filters all the data for eg. All registrations who registered on the 22/10/2008 between 18:00 and 20:00. Thanks ...

How do I track a repeating calendar event in C# / SQL Server?

I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events. What is the best way to handle tracking this event that can repeat? For example: Should the event be stored once in the database and projected out / r...