datetime

Are leapseconds taken in account in dotNet (or C#)?

Does the DateTime struct takes care of this? Does any other class/struct? UPDATE : I now have read that leapseconds are only announced 6 months in advance, since the rotation of the earth is not that predictable... Since there's no possibility to implement that in future dates, I can imagine they just omitted them? ...

SQL putting two single quotes around datetime fields and fails to insert record

I am trying to INSERT into an SQL database table, but it doesn't work. So I used the SQL server profiler to see how it was building the query; what it shows is the following: declare @p1 int set @p1=0 declare @p2 int set @p2=0 declare @p3 int set @p3=1 exec InsertProcedureName @ConsumerMovingDetailID=@p1 output, @UniqueID=@p2 output, ...

Javascript Unix Epoch Time Strangeness

I have a portion of script that calculates the days remaining to an event: var currTime = Math.round(new Date().getTime() / 1000.0); var dispDate = event.find('UnixEpoch').text(); var diffDate = (dispDate - currTime) / 86400; var dateRound = Math.round(diffDate) - 30; The first line gets the current Unix Epoch time and shaves off the ...

datetime for a asp.net cms

Hi, what things do I have to consider when dealing with datetime in a asp.net web application? I am also using sql server. How can I ensure I don't run into problems with dates? (don't want to release it and THEN deal with it hehe) ...

DateTime to Single with C#

Hi, I'm trying to build an interface between iTunes e MediaMonkeys. When I imported my tracks from iTunes to MM, the field LastPlayed wasn't considered. So I decided to build an interface that reads the value from iTunes and updates the MM database. I'm using the package from phxsoftware in order to access the SQLite database used by ...

how to validate dates in asp.net

Hi, I have been having this issue with dates since "ever" I live in a country where we use the british date formats e.g. dd/mm/yyyy but everytime I try to do a query to a sql db hosted in a US server, 100% of the time I come accross to errors. Convert.ToDateTime("2007-17-5") produces an error where as Convert.ToDateTime("2007-5-17") ...

Fill combobox with english months

I have to fill a combobox with month in English: January, February, etc. I did it next way: private string[] AmericanMonths { get { var arr = new string[12]; var americanCulture = new CultureInfo("en-US"); for (int i = 0; i < 12; i++) { arr[i] = new DateTime(2000, i + 1, 1).ToString("MMMM", americanCulture); ...

Using Insert throws Exception on Datetime field

When trying to execute an Insert comment using the Insert CLass I get the following Exception: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. I am uing the following globalization settings: <globalization uiCulture="en-AU" culture="en-AU"/> And my date format is :"dd/mm/YYYY" ...

How to handle timezones in CFML?

How to handle timezones in CFML? So far all apps I've wrote just use the default timezone of the CF server and/or SQL server. What do you guys usually do? Do you store all dates in GMT with GetTimezineInfo() and then DateAdd(), and translate all time to the correct timezone based on logged in user's preference? Or do you guys use any...

Python - Can't subtract offset-naive and offset-aware datetimes

I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it's age. The problem I'm having is that both datetime.datetime.now() and datetime.datetime.utcnow() seem to return timezone unaware timestamps, which results in me getting this error: TypeEr...

Print long integers in python

If I run this where vote.created_on is a python datetime: import calendar created_on_timestamp = calendar.timegm(vote.created_on.timetuple())*1000 created_on_timestamp = str(created_on_timestamp) created_on_timestamp will be printed with encapsulating tick marks ('). If I do int() or something like that, I'll get something like 12408...

Ruby Time.parse gives me out of range error

I am using Time.parse to create a Time object from a string. For some reason Time.parse("05-14-2009 19:00") causes an argument our of range error, whereas Time.parse("05-07-2009 19:00") does not Any ideas? ...

Lilian Date function in SQL Server 2008

I am working with an AS400 database and SQLServer 2008. I would like a way to convert a date in say, MM-DD-YYYY into lilian format and back in T-SQL. Anyone know of any? Even if I convert the data that I had in the AS400 into SQLServer 2008 I believe I will still need the same function. ...

How to read an xsd:dateTime with msxml?

I'm using the msxml to parse an xml file. Language is C++. The xml file contains some dates and times using the xsd:dateTime format (Something like that: 2009-04-29T12:00:00Z) Is there an easy way to convert xsd:dateTime to something like SYSTEMTIME, FILETIME or VariantTime? ...

How to subtract two dates, ignoring daylight savings time in PHP?

I'm trying to calculate the number of days between two days, but I'm running into issues with Daylight Savings Time. Here's my code: function date_diff($old_date, $new_date) { $offset = strtotime($new_date) - strtotime($old_date); return $offset/60/60/24; } Works fine as long as the days are both within the same DST period: e...

Stumped on C# DateTime ToString() formatting problem

I am getting some junk data returned from a ToString() call on a DateTime object in C# and I'm afraid I'm stumped after poking around with it for a while. The function is supposed to format dates to be compliant with RFC 822 (as required by the RSS spec) and looks like: public static string FormatPubDate(DateTime pubDate) { string...

How can I compare time in SQL Server?

Hi! I'm trying to compare time in a datetime field in a SQL query, but I don't know it it's right. I don't want to compare the date part, just the time part. I'm doing this: SELECT timeEvent FROM tbEvents WHERE convert(datetime, startHour, 8) >= convert(datetime, @startHour, 8) Is it correct? I'm asking this because I need to know...

DateTime difference operator considers daylight saving?

As far as I know the difference operator of the DateTime type considers leap years: so new DateTime(2008, 3, 1) - new DateTime(2008, 2, 1) // should return 29 days new DateTime(2009, 3, 1) - new DateTime(2009, 2, 1) // should return 28 days But what about daylight saving? ...

Need Help to Converting Delphi Time to .Net Time

I am porting a Delphi application to C# and I've run into a problem. The Delphi app records the time into a log file, which then gets read back into the program. But the format of the time it records confuses me. I can find no .Net library to convert it properly. Delphi recorded time in log file: 976129709 (this gets converted to 1/14/...

How can I calculate the number of days between two dates in Perl?

Heylo, I want to calculate (using the default Perl installation only) the number of days between two dates. The format of both the dates are like so 04-MAY-09. (DD-MMM-YY) I couldn't find any tutorials that discussed that date format. Should I be building a custom date checker for this format? Further reading of the Date::Calc on CPAN ...