datetime

How do I set a full date & time sql using java, and not just the date?

I am trying to set a timestamp in my database using java, however in my table all I get is the date, and no time (i.e., looks like "2010-09-09 00:00:00"). I am using a datetime field on my mysql database (because it appears that datetime is more common than timestamp). My code to set the date looks like this: PreparedStatement ps = c...

Samus Mongodb-csharp Inserting Dates & Querying by Dates

I am using the MongoDB-Csharp driver and I was wondering what the proper way to insert and query date field? I tried using storing the dates using System.DateTime, but I am having issues when I try to query by date. example: Inserting Data var mongo = new Mongo(); var db = mongo.GetDatabase(dbName); var collection = db.GetCollection(...

Parsing Datetime

I have a date time as a string, eg. "2010-08-02", I'm trying to convert it to UTC with the following code snippet DateTime.ParseExact("2010-08-02Z", "yyyy-MM-ddZ", CultureInfo.InvariantCulture) When I print to the console, I get the following: 8/1/2010 5:00:00 PM. Is there a reason why the date shows up as the date before the date I'm...

Simple conversion between java.util.Date and XMLGregorianCalendar

I'm looking for a simple method of converting between java.util.Date and javax.xml.datatype.XMLGregorianCalendar in both directions. Here is the code that I'm using now: import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.X...

SWT DateTime control used as table editor doesn't extend past bottom of table

I'm having trouble with the SWT DateTime widget. I use DateTime, CCombo, and Text boxes as cell editors. CCombo and DateTime may be (and actually, almost always are) taller than the table itself and should extend past the bottom of the table to allow the user to choose any of the entries. CCombo is doing this fine. If there's a sin...

MySQL: Fetching rows added last hour

Hi, I keep a record of logins in a table. I have columns for id, ip, date and time. From that record of logins I wanna fetch logins made only in the last hour. I'm sweaping through the MySQL docs on time and date functions, but I just can't seem to combine them correctly. Can somebody help me? ...

DateTime loses precision when serialized/deserialized

I'm setting a date on a DateTime type field and I call my web service which is located on the same server using WCF: // on the client myObject.Date = DateTime.Now; myChangedObject = proxy.DoNothing(myObject); // passes back the object // on the server public MyObjectType DoNothing(MyObjectType source) { var obj = new MyObj...

First saturday for a selected month and year

How could I find the first Saturday for a given month and year (month & year selected by a calender)? I am using PHP. ...

How can I convert a double into HH:MM:SS in ObjectiveC

I've got a double 0.27392 and I know it is 6:34:27 AM. This is simple in Excel, but I can't get NSDateFormatter to work its magic. ...

Convert DD/MM/YYYY HH:MM:SS into MySQL TIMESTAMP

I would like a simple way to find and reformat text of the format 'DD/MM/YYYY' into 'YYYY/MM/DD' to be compatible with MySQL TIMESTAMPs, in a list of text items that may or may not contain a date atall, under python. (I'm thinking RegEx?) Basically i am looking for a way to inspect a list of items and correct any timestamp formats found...

Simple, concise way to express "tomorrow at 10:30am" using Java standard libraries

Using only standard java 1.5 calls, I'm looking for a concise and simple way to get a java Date object for a specific time, say the next 10:30am that occurs in the future. This will generally be tomorrow at 10:30am, but it may be today at 10:30am if the current time is, say, 8am. Efficiency is only a secondary or tertiary concern. It s...

What's best practice to represent a Time object in C#?

I have a Time column in a DataBase table. The date is not important, we just want a time in the day. What type would be best to represent it in C#? I was going to use a DateTime, but I don't like the idea of having a date. Any idea? Thanks! ...

Best FOSS date picker (maybe time too)?

I don't have time to reinvent the wheel; can anyone recommend a free for commercial use PHP date picker (maybe with an option to pick time too, I'm not sure about that yet). I'd like to show something fairly unobtrusive, maybe a little calendar or clock icon, let the user choose a date (/time) and then display the selection. Hmm, can I...

Importing date & time data from a txt file in Matlab

Hello, I have a txt file from which I want to load date & time data. UI import wizard ignores date & time string and loads only numeric data, which is also present in the file. How can I write a script that would load this date & time data as a vector of multiple values (I mean, 1st date, 2nd date and so on). I know how to manipulate th...

Rails 3 default datetime format without UTC

Hi all, I'm creating a new Rails 3 app, and in it I use datetime for a couple of fields, however every datetime field standard has UTC behind it (in a view), like: 2010-10-10 16:19:00 UTC How do I get rid of the UTC part? UPDATE: here's what I have so far: <%= trip.truckleft.strftime("%Y-%m-%d %H:%M") %> So all I have to do now...

Python: Initialize a datetime object with seconds since epoch

Hi, The time module can be initialized using seconds since epoch: >>> import time >>> t1=time.gmtime(1284286794) >>> t1 time.struct_time(tm_year=2010, tm_mon=9, tm_mday=12, tm_hour=10, tm_min=19, tm_sec=54, tm_wday=6, tm_yday=255, tm_isdst=0) Is there an elegant way to initialize a datetime.datetime object in the sa...

ASP MVC DateTime problem model validation problem

I have MS SQL in my local development server and production server. The DateTime format of my local server is "mm/dd/yyyy" but the format in production server is "dd/mm/yyyy". Every thing worked fine in my local server , but when I try to enter a date like "05/31/2010" in my production server, the Model Validation threw an error "The va...

Date / Time reference table needed for Analytic?

Is it better to keep Days of month, Months, Year, Day of week and week of year as separate reference tables or in a common Answer table? Goal is allow user content searches and action analytic to be filtered by all the various date-time values (There will be custom reporting for users based on their shared content). I am trying to ensure...

inserting Datetime into SQLCE with milliseconds C#

I have a string datetime in this format "dd-MM-yyyy HH:mm:ss.fff" like so.. DateTime mydate = Convert.ToDateTime("13-09-2010 02:30:14.905"); result.SetValue(1, mydate); //I get a error saying 'String was not recognized as a valid DateTime' if i do it this way DateTime mydate = DateTime.ParseExact("13-09-2010 02:30:14.905", "dd-...

php date format

Hi guys, I'm trying to insert the current date from a php form into a database. My query is: $sql3="INSERT INTO orderDetails (compName, package, cost, date) VALUES ('$companyName', '$package', '$cost_record', 'date()')"; This produces the following: 0000-00-00 00:00:00 which obviously isn't right. Can anyone recommend how to g...