datetime

converting a calendar object into a string in java with format "yyyy-mm-dd hh:mm:ss"

I'm converting a date stored in a calendar object in a string for a query in MySQL. I need the string in format "yyyy-MM-dd HH:mm:ss", i.e.: "2010-01-01 15:30:00". I'm using a code like: Calendar TimeStop = Calendar.getInstance(); TimeStop.set(2010, 01, 01, 15, 30, 0); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd ...

Compare dates in DataView.RowFilter ?

I am scratching my head over something rather stupid yet apparently difficult. DataView dvFormula = dsFormula.Tables[0].DefaultView; dvFormula.RowFilter = "'" + startDate.ToString("yyyyMMdd") + "' < EndDate OR EndDate = '19000101'"; dvFormula.Sort = "FromDate ASC"; The result is this: Cannot perform '<' operation on System.String ...

SQL Server DateTime parameter 'rounding' warning

More of a warning than a question: We resolved a very puzzling bug this morning. We have a variety of reports that allow users to enter date ranges they want to run. The assumption is, if you ask for a report from 8/1/2010 to 8/10/2010 you meant to include 8/10/2010 so the end-date of the report isn't 8/10, it's something after that. I...

Creating a "date updated" column in MS SQL?

Is there any simple way to create a column in MS SQL that will track the last time a record was updated? I would like to have two fields. One to track when the record was created. That one is simple. Create a datetime field and set its default to getdate(). However the second field seams to be a bit more tricky. I want it to have the la...

Wordpress: events grouped by month

Hello Within my WP site I have a category called 'events' where I am publishing event information using two custom fields: eventdate = human readable event date eventsortdate = YYYY/MM/DD to list events in the correct order. I have this bit of code from a helpful post here: http://www.davidrisley.com/events-list-with-wordpress/ <?p...

Editing cursor data before ListAdapter displays it in the ListView

I first retrieve information from the SQLite database into a cursor. The cursor contains a timestamp column in the format: yyyy-MM-dd HH:mm:ss.SSS, for example, 2010-08-27 21:25:30.575 Once retrieved, I set aSimpleCursorAdapter like so (code simplified): SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout...

How to use :conditions to compare (a datetime) with (datetime + 'number of days') ?

I'm building an application that checks when a user needs to change the oil of one of his cars. Here's how it works: The user enters the name of his car (e.g. 'Ford Mustang') The user enters the time the car will run on one oil change (e.g. 3.months) The user saves the car to the database Repeat above process for all his other cars. (Y...

Php change date with respect to specified time.

Hi all. I have this question. I am using php, mysql and my files will be hosted on linux machine. Is it possible to change the date on a different format. I mean the date should change if it is 5PM. That is if today is 28th august 2010, then after 5pm it should show 29th august 2010. Thanks a lot. ...

How to filter a numpy.ndarray by date?

I have a 2d numpy.array, where the first column contains datetime.datetime objects, and the second column integers: A = array([[2002-03-14 19:57:38, 197], [2002-03-17 16:31:33, 237], [2002-03-17 16:47:18, 238], [2002-03-17 18:29:31, 239], [2002-03-17 20:10:11, 240], [2002-03-18 16:18:08, 252], [...

How Do I add only TIME in C#

I need to do a calculation for my crystal report. In report, there will be Times(in Hour:Min:Sec)like this.. 00:12:34 00:52:12 23:19:56 and so on.. I need to add them together so that..results will be Hr:min:ss Hr may be more than 100.. but can't change to day How to achieve that? Thanks a lot.. ...

Ruby String to Date Conversion

Hi, I am faced with an issue in Ruby on Rails. I am looking to convert a string of format Tue, 10 Aug 2010 01:20:19 -0400 (EDT) to a date object. Is there anyway i could do this. Here is what I've looked and tried at the following with no luck: Date.strptime(updated,"%a, %d %m %Y %H:%M:%S %Z") Chronic Parser Ruby: convert string to ...

How to transform a dataframe of characters to the respective dates?

Dear all, I noticed already a couple of times that working with dates doesn't allow for using the usual tricks in R. Say I have a dataframe Data with Dates (see below), and I want to convert the complete dataframe to a date class. The only solution I could come up with until now is : for (i in 1:ncol(Data)){ Data[,i] <- as.Date(Dat...

regular expression for matching date in Perl

I want to match dates that have the following format: 2010-08-27 02:11:36 i.e. yyyy-mm-dd hh:mm:ss. Right now I am not very particular about the date being actually feasible, but just that it is in the correct format. Possible formats that should match are (for this example) 2010 2010-08 2010-08-27 2010-08-27 02 2010-08-27 02:11 20...

MYSQL query / dates older than 1 week ago (all datetimes in UTC)

Hi, How do I query a mysql db to return all records with a datetime older than 1 week ago. Note that the datetime table stores everything in UTC, and i should be comparing it in that itself... Jusst to be clear - I'm looking for a pure mysql query ...

Shortest XPath to find minimum/maximum of sibling dateTime nodes

Hi I have the following simple xml: <root> <item> <d>2002-05-30T09:00:00</d> </item> <item> <d>2005-05-30T09:00:00</d> </item> <item> <d>2003-05-30T09:00:00</d> </item> </root> Now I want to find the minimum or maximum dateTime node using XPath. My solution at the moment is: /root/item[not(number(translate(./d, 'TZ:-', ...

Parsing a strangely formatted DateTime. Anyone fancy stepping up?

Hi folks, I'm trying to parse a datestamp (that I got from Twitter) but am receiving errors. here's the datestamp: Fri, 27 Aug 2010 22:00:07 +0000 Here's my code: DateTime.ParseExact(MyDateValue, "ddd, dd MMM YYYY HH:mm:ss +ffff", new CultureInfo("en-US")) and here's my error: System.FormatException was unhandled Mes...

PHP DateTime::modify adding and subtracting months

I've been working a lot with the DateTime class and recently ran into what I thought was a bug when adding months. After a bit of research, it appears that it wasn't a bug, but instead working as intended. According to the documentation found here: Example #2 Beware when adding or subtracting months <?php $date = new DateTime('...

How can i get current date based on the visitor's country?

I'm hosting my site in US and my site lists events based on time and holidays and birthdays based on dates.. I'm using php and mysql when someone visits my site from india the date that will be shown on the site will be a day lesser.. How can i get the change the date and time based upon the visitor's country? ...

Strtotime returning wrong time value - adding 8 minutes on its own?

Hi guys, I'm taking a string which represents a time value and am storing it in a database table where the field type is also a time value. The problem is that I try to first format the string to be of a date time format using the code: date('H:m', strtotime($value)); The issue is that its returning the time but with 8 minutes increme...

vb.net convert string to date

hello, how do i convert the string 30.10.2009 in date? (dd.mm.yyyy) thanks :> ...