datetime

Query To Get Consecutive Events If They Are Close Enough

This is my table structure: monResults: id Int(10) monDateTime Datetime() typeId int(10) I need a query to get all monResults that have consecutive monDateTimes that are less than 1 minute apart and have the same typeId. I want to be able to get X number of these events. Mostly I don't know how to add the condition to make consec...

How to alter a DateTime field when it is updated?

Is there a database level function (trigger or something) that I can use to alter a DateTime field when new data is inserted? The issue is that a service I am integrating with happens to send out all of its times (in this case the time some info was received on their end) in GMT. I need to automatically change this to reflect the time ...

ISNULL Date month

Hi I have two dropdownlists, one with months and the other one with year. The user selects the submit month and year for the items they want to retrieve. In database the date is entered in full eg. 01/12/2009. There is an option for "All years" and "All months" in the dropdown lists but when users choose either they get null results. Ma...

C# : How to convert string to DateTime, where the string can have any of the standard datetime format ...

I had posted a question on DateTime to String conversion, I got many satisfying answers for that .. so I thank StackOverflow very much .. Here is one more problem of String manupulation, I am stuck with .. I have to convert a string (from some external source) using C# code .. the string can have these expected format of DateTime .. 02...

How to compare datetime in Django?

Suppose I have: ds = datetime.datetime.now dd = Entry.objects.get(pk=id).pub_date How to compare 2 objects above? I want to get the time difference between them. Please help me solve this problem. Thank you very much ! ...

Best way to return array of counted values for multiple date ranges in Rails

I'm trying to return an array of counted values for consecutive date ranges (that will vary in distance), so that I have something like the following: counted_values = [2,0,4,5,6,0,0,4,2] So far I've written something that works but makes me shudder slightly, as I'm sure there's a more Rubyist/Rails way of doing it. Current code: ...

Current Datetime in PHP

Hi all I can't just make this work. How can i display the current date in PHP in the format YYYYMMDDHHMMSS. Regards Matt ...

How to select records from last 24 hours using SQL?

What where clause should be use to get records from the last 24 hours? ...

How do I combine data from two DateTime columns (SQL Server)?

Using SQL Server 2005, I am working with a database which has two columns to keep track of what is essentially a single DateTime (and I can't for the life of my figure out why anyone would ever think this is a good idea). Basically, one column, let's call it OrderDate, contains a DateTime like this: 2008-02-29 00:00:00.000, and the oth...

BlackBerry - Creating custom Date Field

i want to create a field that looks like this ....can any one tell me how this could be done which field could i use where in i can select values by using the trackball/wheel or in case of storm i could slide... ...

mysql+php to subtract two times and display the differrence

hi!! i've to display the differences between a column(reg_time) in mysql and the present time so that the final output (after some php to display in minutes or seconds or hours or days) be: Registered : 8 hours ago. is there any function to do that? thanks ...

Getting a boolean from a date compare in t-sql select

I am wondering if something along the lines of the following is possible in ms-sql (2005) SELECT (expiry < getdate()) AS Expired FROM MyTable WHERE (ID = 1) I basically want to evaluate the date compare to a boolean, is that possible in the select part of the statement? ...

MySQL Default DATETIME value

I'd like to accomplish something like the following in a MySQL Create table action date_created datetime NOT NULL DEFAULT CURRENT_DATETIME, date_updated datetime NOT NULL ON UPDATE CURRENT_DATETIME, Once again, this is a MySQL create table action and these are two of the fields in my table. ...

Get first day of week in PHP?

Given a date MM-dd-yyyy format, can someone help me get the first day of the week? ...

Problem saving time in rails.

I have an application which save datetime using Time.now, but when I retrieves it and compare with Time.now again it not the same format and result in unexpected result. What should I do to always make this time standard all the time. Thanks, ...

How to calculate how many years passed since a given date in Ruby?

This question was here for other languages, so let here be one for Ruby. How do I calculate number of complete years that have passed from a given date? As you probably have guessed, that's to calculate person's age automatically. The closest one is distance_of_time_in_words Rails helper, so the following template Jack is <%= distanc...

subtract 2 datetime fields to get the days left difference

Would appreciate it if anyone can help me figure out to substract 2 datetime fields to get the days left difference. ...

DateTime question

Hi, I have 2 DateTime objects, which I save to a file after using the ToShortDateString() function; the strings look like "12/15/2009". I am stuck on this part now, I want to initialize DateTimeObject(s) with these strings so I can compare the timespan between the date dates. Any help appreciated. ...

How do I check if it's Monday to Friday and the time is between 10 AM to 3 PM?

In python how do I check if its a weekday (Monday - Friday) and the time is between 10 AM to 3 PM? ...

MySQL Using a string column with date text as a date field

I am doing a database migration and I currently have a string column with dates (versus having the optimal datetime field set for these). Is there a function I can call in MySQL to convert this field to a datetime so I can use the date features such as before this date or after this date? ...