datetime

Serialize and Deserialize Date between ASP.Net MVC and ExtJS

I've been searching through the web to look for a solution for this but still stuck. I'm having difficulties serializing DateTime object. The standard serialize using DataContract will give this result \/Date(1262600239000)\/. After Ext.encode the result changed to /Date(1262600239000)/. The result from Ext.encode is not readable in Ext...

How to set timezone for SQL?

I'm using SQLite for my cgi application, but the timezone I'm in is different from that of the shared server this stuff is running on. Can I set my timezone somehow in SQLite so I don't need to mess up my application with time conversions and I can use things like NOW() in my SQL? If not: what are my other options? ...

What's the optimum way of storing an NSDate in NSUserDefaults?

There's two ways of storing an NSDate in NSUserDefaults that I've come across. Option 1 - setObject:forKey: // Set NSDate *myDate = [NSDate date]; [[NSUserDefaults sharedUserDefaults] setObject:myDate forKey:@"myDateKey"]; // Get NSDate *myDate = (NSDate *)[[NSUserDefaults sharedUserDefaults] objectForKey:@"myDateKey"]; Option 2 - t...

LinqToSql with dates problem

Hi, I have a simple LinqToSql query from p in GL_PROJECTs where p.CREATE_DT == new DateTime(2009,10,26) select new p Some of the records in the database have create dates with time parts other than 00:00:00, so wont be retreived by this query. What I want to achieve is a time insensitive retrieval for the whole day. I tried the fol...

Reffering to text from cell of WPF DataGrid.

I need to get datetime from SQL table but I have two problems: I need to refer to string from selected cell of DataGrid. I've tried "bksDataGrid.CurrentCell.Item" but that doesn't work. Not really problem, but the cmd will return SQL datetime as object. Is it possible to convert it to .NET DateTime? object obj = new object(); ...

.NET: Why is TryParseExact failing on Hmm and Hmmss?

I'm trying out the DateTime.TryParseExact method, and I have come over a case that I just don't get. I have some formats and some subjects to parse that each should match one of the formats perfectly: var formats = new[] { "%H", "HH", "Hmm", "HHmm", "Hmmss", "HHmmss", }; v...

Best way to check if column returns a null value (from database to .net application)

I have a table with a DateTime column the column can have NULL values Now I connect to the database using an ODBC connection and get the value into a DataTable in .net / c#. I am able to check it for NULL by going if(String.IsNullOrEmpty(table.rows[0][0].ToString()) { //Whatever I want to do } Is String.IsNullOrEmpty the correc...

Finding weekend days based on culture

Is there a way to find the days that constitute a weekend or workweek based on different cultures using the .NET framework? For example, some Muslim countries have a workweek from Sunday through Thursday. ...

Calculating the time difference in an php/mysql/javascript system

I was wondering what the best way is to calculate the difference in time from now to a certain point, lets say the countdown time. I have an auction that has a closetime at a certain point, this time is stored in an mysql record in the format " DATETIME 00-00-000 00:00:00 ". This record is called closetime. Now on my website i have a j...

Date.getHours() in JavaScript looks broken to me.

This snippet displays 1. Why is it so? I use constructor as in new Date(milliseconds) //milliseconds since 1970/01/01. I expect it to be midnight, so 0 hours. But why does it return 1? var milliseconds = 0; var d = new Date(milliseconds); alert(d.getHours()); ...

How to get the DateTime when the current process started?

................. ...

Date Display problem in ColdFusion

When I retrived a Date field in TOAD it displayed like is '1/18/2038 9:14:07 PM', But when I rertrived in Coldfusion using cfquery and displayed using , then I got the date on screen like '2038-01-18 21:14:07.0'. Does anyone have idea why it displayed in different format? Is there anyway we can make it display like TOAD format? I am...

Codeigniter: return datetime from db formatted

I'd like to format a datetime entry stored in a SQL db in a friendly format. I'm just returning a simple query as a row(date)... Is there a quick/easy way to do this? I can post examples, if need be. Right now the query is in a foreach loop: <?php print $row['exp_date']?> ...

SQL Server: Group results on time interval

Hey guys, I've got an MS SQL Server table that records our plant's alarm events with a row for each alarm and a datetime column to capture when the alarm happened. We run our plant in 12 hour shifts (6 am to 6pm, 6pm to 6am) and I need to figure out how many alarms we're getting each shift. How do I group my results to get that? The...

Problems adding time

I've run into a strange timewarp while doing some math with time, and it has left me stumped. Or, well, I've found the reason (or atleast a plausible one), but don't quite know what to do about it, or if there is indeed anything that can be done. The issue in plain words is, that when adding time in larger units than 1 week (it's multip...

unix shell script to get date 30 minutes ago in GMT

Hi, I have a shell script that I want to get the date and time 30 minutes ago in GMT. I have this working great for full hours, but partial hours don't seem to work: 1 hour ago TZ=GMT+1 date +%Y-%m-%d" "%H:%M:%S 2010-01-08 17:43:57 2 hours ago TZ=GMT+2 date +%Y-%m-%d" "%H:%M:%S 2010-01-08 16:44:07 1/2 hour ago TZ=GMT+.5 date +%Y-%...

vb.net dropdownlist populate

i need to populate my dropdownlist with month and year values to getdate + 1 year. I also want them in text format so "January 2009 and not 1 2009. This is the code i have written to populate the values. how do i convert them to January from 1? Public Sub Load_xxxx(ByRef DDL As System.Web.UI.WebControls.DropDownList) Try ...

convert string to datetime vb.net

i need to convert strings to date format. the requirement is if current month is selected, the date should be getdate. if any other month is selected then it should be first of that month. the data coming in is "January 2010", "February 2010" and so on. but it should be inserted into sql server database as 01/01/10 or 02/01/10 ...

Timezone help in PHP/MySQL

I have been fighting the timezone battle for weeks now, everyone thinks they know the solution and then they get a million upvotes but the reality is I am totaly 100% stuck, no answer ever given for timezone support in PHP/MySQL has worked 100% for me, so I am asking the question again on here in as much detail as I possibly can with cod...

DateTime precision in NHibernate and support for DateTime2 in NHibernate SchemeExport

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO class: public class Foo { public virtual int Id { get; set; } public virtual datetime CreatedDateTime { get; set; } } The CreatedDateTime field will map to a SQL DateTime by default. However if I do a test to check ...