datetime

How to improve the following SQL select date in RDB

I'm working on a .Net WinForms appliation that is connecting to a legacy RDB database... Some of the fields for dates are stored as integers (imagine 2010-01-04 was the integer 20100104) In the .Net world, I'd much rather work with datetime objects and I've been able to convert the integer into a date, just that it looks so ugly, takes...

How does ADO.NET store dates and time?

I was lazy and write an insert statement with DateTime.Now. It occur to me later i should have written DateTime.Now.ToUniversalTime(). This got me thinking, does ADO automatically convert dates into universal time? and restore it to local when i pull data out? Or do i need a write ToUniversalTime and ToLocalTime myself in every area of c...

sql compare datetime today

Hi I hope anyone can translate my abstract query. I want to select * from TABLE where ( [MYDATETIMEROW] < (TODAY - 3 Days)). Does I have to Convert, cast or use datepart or anything else?.. im confused. Are there simple rules? I would'nt have problems to do that with linq but simple sql I learned just hardly. Thank you and best rega...

DateTime.Parse issue, not support in System.Globalization.GregorianCalendar

I'm having an issue where a specific time string, contained in the Gmail Atom feed isn't parsing using DateTime.Parse(). I understand I could use DateTime.TryParse(), but I'm curious to why these two don't work, where as all of the rest do. 2009-12-28T24:11:48Z 2009-12-30T24:16:20Z the specific exception is: System.FormatExceptio...

DateTime.ParseExact string format exception.

I am trying to convert a string into datetime with the following C# code, DateTime dTo = DateTime.ParseExact(dateTo, "mm/dd/yyyy", CultureInfo.InvariantCulture); eachtime I pass dateTo as 1/1/2010 it fails, instead it needs the string to be 01/01/2010. What string format should I use to support both 01/01/2010 and 1/1/2010? ...

Should I use a timestamp or text field in MySQl for UTC time/date

I read a mysql timestamp can only hold a value from 19700101000000 to sometime in the year 2037. I seriously doubt my app will be around then, well i'm sure it wont but any idea what will people use then for a timestamp, a text field? Below is an example of how I currently insert a mysql record with a datetime mysql field and you can ...

Create a function to return current date and time in oracle

Hello, I am new to oracle, I have to create a function that returns current date and time. I am using this to return date; SELECT CURRENT_DATE FROM dual; Thanx ...

Objects in PHP: More or Less is better?

I have asked aqbout timezones and date/time before but this is a more specific question, more about Objects in PHP. <?PHP //set the user's time zone on page load date_default_timezone_set("America/Los_Angeles"); //convert the timestamp from DB into the user's time $timestamp = '2008-05-01 13:44:19'; //this would normally be returned ...

what do you call a date/time with a T in the middle (2008-09-18T00:00:00)?

If you have a date like '2008-09-18T00:00:00' does it have a name? UTC? Something like that? Surprisingly hard to google for this... ...

Using DateTime.TryParseExact without knowing the year

I have a method that (sometimes) takes in a string in the format "dddd MMMM dd" (Monday January 04) that needs to get parsed into a DateTime. I say sometimes because it may also get passed in "Today" or "Tomorrow" as the value. The code to handle this was simple enough: if (string.Compare(date, "Today", true) == 0) _selectedDate = ...

Can I tell activerecord to not convert "datetime" data to objects when I access?

I have some code that simply accesses a datetime field so activerecord converts it to a Time object automatically when I read it: @some_appointment.some_time The problem is that sometimes the "some_time" datetime column has bad data. "0209-12-20" instead of "2009-12-20". This causes to Ruby to throw a "year too big to marshal" error...

How can I get the current week using Python?

Using Python... How can I get a list of the days in a specific week? Something like... { '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/2010'] } The key of the dictionary in this example...

How can I select all of the Sundays for a year using Python?

Using Python... How can I select all of the Sundays (or any day for that matter) in a year? [ '01/03/2010','01/10/2010','01/17/2010','01/24/2010', ...] These dates represent the Sundays for 2010. This could also apply to any day of the week I suppose. ...

Ruby - DateTime for Database

Hello! I have a Database column with the syntax "0000-00-00 00:00:00". In PHP I would do date('Y-m-d H:i:s'); In Ruby, I do require 'date' now = DateTime::now() puts "#{now.year()}-#{now.mon()}-#{now.mday()} #{now.hour()}:#{now.min()}:#{now.sec()}" The result is: "2010-1-5 10:16:4" That's not okay. How could I create a "timestring...

PHP mySQL - UNIX_TIMESTAMP is not equal to strtotime

Hi all, PLATFORM: PHP & mySQL I am storing the date+time in database in the following format: date("Y-m-d H:i:s"). An example of a value that I have in my DB is : 2010-01-05 07:36:33. In my script, I have set the timezone as date_default_timezone_set("America/Chicago"); THE PROBLEM: I read about the UNIX_TIMESTAMP somewhere and I w...

Date Range Query MySQL

I need a query to select data between two dates with today's date as a reference. The database has a datetime field for "start" and a datetime field for "end". $todays_date = date("Y-m-d H:i:s"); $q = "SELECT * FROM news WHERE `end` >= '" . $todays_date . "' AND `start` >= '" . $todays_date . "' ORDER BY id DESC"; The problem is t...

Date formatting in PHP

Hello, I've a date formatted like "Tue Jan 05 11:08:27 +0000 2010" and I want to convert it's format to "yyyy-mm-dd 00:00" in PHP. How can I do that? ...

Using Groovy(or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.date?

Using Groovy (or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.Date? import org.joda.time.* Calendar cal = Calendar.instance cal.set(Calendar.DATE, 1) cal.set(Calendar.HOUR, 0) cal.set(Calendar.MINUTE, 0) cal.set(Calendar.SECOND, 0) cal.set(Calendar.MILLISECOND, 0) Date startOfTheMonth = cal....

Equivalent of DateTime.Now in Java?

How do I get the current date in Java? In C# it is DateTime.Now. ...

DateTime formatting in .Net for MySQL database

How do I format the string result of DateTime.Now in C# for insertion into a MySQL database table column of type DATETIME? I have tried the following without any success: insert blah (Id, Content, DateCreated) select 123, 'Blah blah blah', 1/5/2010 9:04:58 PM insert blah (Id, Content, DateCreated) select 123, 'Blah blah bl...