datetime

Nullable DateTime in NHibernate 2.0.1

Two issues that will likely be immediately obvious, but I've spent too long already tracking them down: I've set up an AuditInterceptor in order to do automatic auditing on entities that implement my IAuditable interface which is used as follows: public class AuditInterceptor : EmptyInterceptor { public override bool OnSave(object...

NHibernate 2.* mapping files: how to define nullable DateTime type (DateTime?)?

I know one of the breaking changes with NHibernate 2.* is that the NHibernate.Nullables are no longer supported. Therefore, what do you use in your mapping file to map the nullable DateTime? type? For i.e.: Understandably doesn't work: <property name="CreateDate" column="CreateDate" type="DateTime?" not-null="false" /> And no longer ...

Return index value datetime.now.dayofweek but how?

is there any function of datetime return dayofweekindex? such as: int Todaywhat_is_Index= = DateTime.Now.IndexOfDayofThisWeek; if Today is friday, it must be return 5 ifToday is Saturday, it must be return 6 ifToday is Sunday, it must be return 0 ...

Deploying applicaion in different locale than devlopment locale

My .Net .exe is used to read a file and store information in sql DB. On the dev system we had default setting and files in US locale and things were working fine. I used the same .exe and deployed on to our Prod server where the default setting and files are in UK locale. I have used the Datetime.Parse which should be parsing the date...

Linq to sql, summing timespan?

I have a time field in a mssql 2008 database that I want to do something to the effect of: Timespent = x.sum(x => x.AmountOfTime); Where AmountOfTime is a time MSSQL field. Sum seems to only work on decimals, how can I add these columns? ...

How can i learn mytime pre midnight or after midnight?

i send any function a datetime is_PM_AM("23:00.00") if it is pm ,it must be return true or else? But how? mytime ="23:30:00" function(Datetime mytime) { if (Datetime.midnight < mytime) { return true; } else return false; } Can you help me? ...

mysql - unix time vs datetime

I'm writing a php/mysql application which is similar to website visitors tracking solutions. It will handle 100,000s of inserts a day and will be able to be queried by counting pageviews/day etc... I wonder if from terms of performance its better to keep time as integer (unix time) or as mysql time. Any idea on effect on performance? S...

Print Date and Time In Visual Studio C++ build?

How would I print the date and time for the purposes of the build. Ie: When the console for my application starts up I want to do this: Binary Build date: 03/03/2009 @ 10:00AM I think this would be a super useful function for all applications to have behind the scenes for programmers, especially in a team environment. Is there a si...

Leap year bug calling ToUniversalTime().AddYears().ToLocalTime() ?

I encountered what may be a leap year in .NET's DateTime handling, specifically ToLocalTime(). Here's some code which reproduces the problem (I'm in the Pacific time zone): DateTime dtStartLocal = DateTime.Parse("2009-02-28T23:00:00.0-08:00"); DateTime dtEndLocal = dtStartLocal.AddYears(3); DateTime dtStartUtc = dtStartLocal.ToUniversa...

Natural language date parser for ruby/rails

Does anybody know of something similar to Date.js in Ruby? Something that would be able to return a date object from something like: "two weeks from today". The Remember the Milk webapp incorporates this feature into their system and it is incredibly easy to use. I would use the Date.js library itself but because it is on the client sid...

datetime time zone conversion in .net web service

I have a web service (actually a silverlight enable wcf service, but for all intents and purposes, it's a web service) with a method taking a datetime parameter. The method gets called from a client, which could be in a different time zone. The service hosting the web service is in pacific standard time, and it appears the web service ...

why is LINQ to SQL tricked by an extension method? what now?

Consider my Event class, and that i store DateTime's in the DB as UTC dates. I simply want to return a filtered range based on the current date in a particular time zone - easy right? This works fine: IQueryable<Event> test1 = this.GetSortedEvents().Where(e => e.FinishDateTime.Date >= DateTime.UtcNow.Date); This also works fine: IQ...

Difference in server times

I'm developing a web site which will retrieve SMS messages that have been sent to a gateway. The gateway is accessed via an API, with the requests in the following format: http://www.smsgateway.com/?login=myusername&amp;password=mypassword&amp;lasttime=1236164238 Notice that I'm having to track the last time messages were downloaded -...

Help me translate long value, expressed in hex, back in to a date/time

I have a date value, which I'm told is 8 bytes, a single "long" (aka int64) value, and converted to hex: 60f347d15798c901 How can I convert this and values like this, using PHP, into a time/date? Converting it to decimal gives me: 96 243 71 209 87 152 201 1 A little more info: the original value is a C# DateTime, and should repres...

How can I group by specific timestamp intervals in C# using LINQ?

I have a list with tick objects including a pair of a double value and a timestamp. I want to separate the list into child-lists depending on a time interval (for example 15 minutes). One list only has the tick objects from: 8:00:00 - 8:14-59 usw usw C#-code: var result = from tick in listTicks group tick by tick.timestamp.Hour; Th...

What does Windows FILETIME contain? Trying to convert to a PHP date/time.

I've determined that I need to convert a Windows FILETIME type to something PHP can work with. I want this to be a PHP function. Say I have this value: 60 F3 47 D1 57 98 C9 01 Step 1: (Thanks to this page http://www.cyanwerks.com/file-format-url.html) I know I need to change the order to 01 C9 98 57 D1 47 F3 60 Step 2: ????? ...

What's the best way to compare the equality of two DateTime's in C#... but only to a certain precision?

I have two datetimes, one from a timestamp, and another I'm generating in code. I need to test their equality, and would love to do it without too many expressions. Here's an example of my two dates: DateTime expireTimeStampUTC = DateTime.Parse(UTCValueFromDatabase)); DateTime expectedExpireTime = DateTime.UtcNow.AddHours(Nu...

write a batch file to remove the folders by date and time wise

Exact Duplicates: How to write a batch file to delete the files which are 5 days or older from a folder? write a batch file to delete 6 days older files from a folder write a batch file to delete 5 daya older files from a folder How do I write a batch file to delete folders and files on a time basis? How do I create a batch script that...

c# and Date Culture Problems

I've written a asp.net app and one of my postback routines simply saves user submitted form data to a sql 2005 db. All runs great on my development machine but when I deploy to the live site I'm getting invalid dates from my parse date checker. Basically it is expecting an american date format on the live machine but this is not what I...

Tool/library for calculating intervals like "last thursday of the month"

I'm looking for a command line tool or some sort of python library (that I can then wrap), so that I can calculate dates that are specified like "last thursday of the month". i.e. I want to let people enter human friendly text like that above and it should be able to calculate all the dates for any month/year/whatever that fulfil that. ...