datetime

How do I format a date column in MySQL?

My query returns the row value as "2/27/2010 12:00:00 AM" but I need to get "2/27/2010". What do I use to get the format as I need it for MySQL? ...

Sending time with timezone from PHP to flash

I am trying to send the time to flash but set to the currently timezone. When you view the below even though the echo date, looks like its working the $time is the same. When i test in flash I get the extra hour added. Any help tips welcome on this one... $format = "d/m/Y H:m:s"; $timezone = "Europe/Amsterdam"; date_default_timezon...

String to datetime

I have a string 12012009 input by the user in ASP.NET MVC application. I wanted to convert this to a DateTime. But if I do DateTime.TryParse("12012009", out outDateTime); it returns a false. So I tried to convert 12012009 to 12/01/2009 and then do DateTime.TryParse("12/01/2009", out outDateTime); which will work But I don't find any s...

Convert date in text format to datetime format in T-SQL

I have a client supplied file that is loaded in to our SQL Server database. This file contains text based date values i.e. (05102010) and I need to read them from a db column and convert them to a normal date time value = '2010-05-10 00:00:00.000' as part of a clean-up process. Any guidance would be greatly appreciated. ...

Convert date/time string value to .NET DateTime

Hi guys, i've this string example value: Sun, 09 May 2010 11:16:35 +0200 I've to insert it into MySql Date/Time field. How can i convert it into .NET format (or Mysql format), so i can make my INSERT INTO mydate='2010-05-09 11:16:35' ? Thank you ! ...

JodaTime DateFormatter to display milliseconds if nonzero

I want to display a list of dates that may or may not have milliseconds on them. If a certain entry has milliseconds, then it should be displayed like yyyy MM dd HH:mm:ss.SSS. If it doesn't have the millis, I need it displayed as yyyy MM dd HH:mm:ss. I suppose the general question is: Is there a way to describe an optional format stri...

C#: Using DateTime.Parse with string

Hi all.I am trying to get date format from Day name and time like "Monday" and second string "08:15" and it must like 10:05:2010 08:15 and then I will make subtracting from date of today. DateTime.Parse("08:15") it works but it outputs today`s date. I want to get date of day name. I also used DateTime.Parse("08:15").AddDays(1...

Parsing a DateTime containing milliseconds fails for certain cultures. Why?

I'm trying to parse a string containing milliseconds like this: string s = "11.05.2010 15:03:08.7718687"; // culture: de-CH DateTime d = DateTime.Parse(s); // works However, for example under the de-DE locale, the decimal separator is a comma (not a dot). So the example becomes: string s = "11.05.2010 15:03:08,7718687"; // culture...

Give idea to display the datetime in my aspx page.like digital clock

Each and every second the datetime will be updated like a digital clock. formate like:YYYY:MM::DD:HH:MM:DD:A.M ...

DataTable.Select Behaves Strangely Using ISNULL Operator on NULL DateTime Column

I have a DataTable with a DateTime column, "DateCol", that can be DBNull. The DataTable has one row in it with a NULL value in this column. I am trying to query rows that have either DBNull value in this column or a date that is greater than today's date. Today's date is 5/11/2010. I built a query to select the rows I want, but it di...

Date format strings in .Net and Java

I have an application that runs on both C# .Net and Java. Two entirely separate but identical code bases. The problem Im having is formatting date and numbers. For example: A user running the .Net variant is inputting a date and a format string. The 26th of April 1986 is formatted 1986-04-26. The actual date, along with the format stri...

Indexing datetime in MySQL

What is the best way to index a datetime in MySQL? Which method is faster: Store the datetime as a double (via unix timestamp) Store the datetime as a datetime The application generating the timestamp data can output either format. Unfortunately, datetime will be a key for this particular data structure so speed will matter. Also,...

How to subtract dates in YYYYMMDD format?

I have 2 integer fields that represent dates in the YYYYMMDD format. What is the best way to subtract 2 of these fields to get the correct # of days between them? For instance, if I take the difference between 20100511 and 20100428 I would like the result to be 13 and not 83. I know I need to convert the integer fields into date forma...

Correct Time Display

Guys, I''m looking to get this correct and i'm getting a bit fustrated with this. What I want to do is get hours and days and weeks correct. Example: if this post is < 60min old then have it read: Posted Less then 1 minute ago if this post is < 120min old then have it read: Posted 1 hour ago if this post is > 120min old then have it...

SQL server datetime column filter on certain date or range of dates

There is an example for today here http://stackoverflow.com/questions/2583228/get-row-where-datetime-column-today-sql-server-noob I am primarily interested in 2008 only. For today it looked like SELECT (list of fields) FROM dbo.YourTable WHERE dateValue BETWEEN CAST(GETDATE() AS DATE) AND DATEADD(DAY, 1, CAST(GETDATE() AS DATE)...

DateTime c# parsing

I try to parse DateTime.TryParse("30-05-2010"), and it throws an exception because it accepts MMddyyyy, and I need ddMMyyyy format. how can I change TryParse format? thanks, Dani ...

Java: Get current Date and Time from Server not System clock

In my Java program, I need to create an instance of the current moment in time. I use Date date = new Date(); This gives me the current date and time as per the host machine's system clock. Is there any way I can get the current date and time from an online server? The world time server perhaps? I have seen this post and it describes...

Date time format problem in c#

Hi I'm working with c# simple application to display system date time. textbox.Text = DateTime.Now.ToString("MM/dd/yyyy"); but it is showing result as : 05-12-2010 What is the problem with this code? or do I need to change any where in the regional settings of my machine. thank you ...

Convert datetime field in sql server 2005....

I have a datetime field which has a value like this 5/11/2010 12:04:20 PM .... I am converting this field convert(varchar, dbo.Clients.CreatedDate,103) as CreatedDate and i get the result as 11/5/2010..... But how to get 11/5/2010 12:04 PM..... ...

c# get start-date and last-date based on current date.....

I am doing an activity monitor based on date which is similar to stackoverflow Today,YesterDay,this week,Last week,this month,last Month..... Based on current date how to get start-date and end-date for all these Today,YesterDay,this week,Last week,this month,last Month in c#? ...