datetime

SQL AVERAGE TIME

I have the following query in MSSQL: select TRANSACTION_TYPE_ID ,COUNT(TRANSACTION_TYPE_ID)AS NUMBER_OF_TRANSACTIONS ,CAST(SUM(AMOUNT)AS DECIMAL (30,2)) AS TOTAL FROM [ONLINE_TRANSACTION] WHERE CONVERT(CHAR(8), CREATED_ON, 114) >='17:30' AND AMOUNT IS NOT NULL AND TRANSACTION_TYPE_ID !='CHEQUE-STOP-TRANS-TYPE' GROUP BY TRAN...

How can I convert a string into datetime in .NET?

How can I convert dates like "Jun 17 2009, 03:37 pm ET" into a DateTime variable using C#? I have tried DateTime.ParseExact but I haven't figured out the correct format to use. ...

Timestamp conversion is off by an hour

I'm trying to parse a twitter feed in django, and I'm having a strange problem converting the published time: I've got the time from the feed into a full 9-tuple correctly: >> print tweet_time time.struct_time(tm_year=2009, tm_mon=6, tm_mday=17, tm_hour=14, tm_min=35, tm_sec=28, tm_wday=2, tm_yday=168, tm_isdst=0) But when I call thi...

Is there a way to compare Date objects ignoring the time?

Is there a way to compare two dates (which include time) ignoring the time? I have a 1/1/2009 8:00am and 1/1/2009 9:00am and I just want to know if it is the same day, without any care to what time it is. I know I can convert the date and compare the strings, but is there another way? ...

How to distribute proportionally dates on a scale with Python

I have a very simple charting component which takes integer on the x/y axis. My problem is that I need to represent date/float on this chart. So I though I could distribute proportionally dates on a scale. In other words, let's say I have the following date : 01/01/2008, 02/01/2008 and 31/12/2008. The algorithm would return 0, 16.667, an...

How can I convert a DateTime value to a double?

How do I convert a DateTime value to a double? ...

Database Records - Effective Start and End Dates and Foreign Keys

Does anyone have any experience having worked with datasets where records become valid and invalid based on an effective start and end date? The issue is when records in these tables have foreign keys to other tables that also have effective start and end dates Seems you have to end up creating new records for just about every table to ...

How can I get all results that are a certain date away from my value?

Using php i want to make the following mysql query SELECT * FROM TABLE WHERE AUTODATE > (24HRS DIFFERENCE FROM CURRENT DATE) the AUTODATE var CURRENT_TIMESTAMP has values in format Y-m-d H:i:s How is that possible? ...

How to add integer column with default of unix timestamp (epoch) in PostgreSQL?

This doesn't work: create table event ( ... time int default date_part('epoch', timestamp 'now'), ... ); ...

Why DateTime.TryParse returning false when given a real year string?

In the code below I am giving the function a sTransactionDate="1999" and I am trying to covert it to a date x/x/1999. DateTime dTransactionDate = new DateTime(); if(DateTime.TryParse(sTransactionDate, out dTransactionDate)) { //Happy }else { //Sad } if the string is "1999" it will always end up in sad. Any ideas? ...

Convert minutes into a week to time using Java's Date and Calendar classes

Overview This is the scenario: I'm given a value which represents a portion of the total number of minutes that exist in a standard week (assuming 10,080 minutes a week and 1,440 minutes a day) starting midnight Saturday (so 0 minutes Sunday @ 12am). I need to convert this minute value into an actual time value (like 8:35am) and I wan...

How can I change a Windows user's regional settings/date format?

I use a VB6/COM+ application which outputs date/time values based on the short date settings in the Control Panel, Regional Settings, for the user that runs it. The program that then parses that output has a configurable setting for the date format it expects, and presents in the UI. e.g. If the regional setting for the user is set to ...

Are Javascript date/time functions dependent on the client machine?

I was wondering if Javascript date/time functions will always return correct, universal dates/times or whether, Javascript being a client-side language, they are dependent on what the client machine has its date set to. If it is dependent on the client machine, what is the best way to get the correct universal time? ...

How to store datetime in database if time portion is optional?

Should I store it in a single timestamp/datetime field or separate date and time fields? I prefer to store it as a single timestamp field but I need to know when a user didn't enter a time portion. How to best store this in the database? I'm using postgresql. Thanks. ...

Converting .NET DateTime to JSON

Hi, My webservice is returning a datetime to a jQuery call. The returned data is /Date(1245398693390)/ How can I convert this to a javascript friendly date? ...

Wrong time on SQLite timestamp on the iPhone

From my iPhone app I insert some data in my sqlite database that include a date using the CURRENT_TIMESTAMP default value. Everything works great except for the fact that the time is 1 hour behind the time it should be. And that happens both on the device and the Simulator. Any sqlite settings (like current time) i can access somewhere? ...

Handle negative time spans

in my output of a grid i calculate a TimeSpan and take its TotalHours ex. (Eval("WorkedHours") - Eval("BadgedHours")).TotalHours goal is to show this TotalHours as : 39:44 so. First value 7.5 to 07:30 no problem.. but if its negative! I can create a TimeSpan object from Hours with TimeSpan.FromHours( (Eval("WorkedHours") - Eval("Ba...

Filtering by date substrings in Rails

We have a grid control that allows a user to filter text in different fields. A number of these fields might be timestamps, like created_at and updated_at. Now, a user can do many different types of filters, including >, <, >=, <=, etc. So, a query that comes across from the control might look like: "created_at > 2009", or "created_at ...

Validating rfc2616 date string with PHP

For security, requests to a PHP webservice will require a Date: header. I need to calculate if the Date: header is within 15 minutes of the computer clock. I can easily do this by comparing $dt = new DateTime($_SERVER['HTTP_DATE']); to the actual date. However, strotime also supports formats such as "now", which will always be 'valid...

compare two datetime values from SQL Server with c#

i want to know how compare two datetime values one who is retreived from sql database and the other is the current one with c# ...