datetime

Conditional time display

In the mailbox section of my Rails app, I simply display the timestamps of each message as follows: <%= message.created_at.utc %> But I want to change it so that if the message's date is different to today, then display the date, otherwise just display the time (e.g. like Gmail). ...

Get string representation of a sql DateTime day

Hi all, Let's say i have a sql datetime of '1 May 2009' or '12 May 2009'. Is there any built in sql function / operation i can perform on the dates above to return the string representation of the DAY of the date? So for '1 May 2009' i'll get "Friday" as the answer (case not important). For '12 May 2009' i'll get "Tuesday". ...

Simple formula for determining date using week of month?

Given a standard piece of scheduling information, such as "the second Tuesday in June 2009" or "the last Friday in July 2009", what's the simplest and most efficient formula to translate that into a date? Inputs: w = Week of month, enumeration (1st, 2nd, 3rd, 4th or Last) d = Day of week, enum Sun through Sat m = Month, integer y = ...

Crystal Reports DateTime.MinValue

Hello, I want to know the minimum value of the Crystal Reports datetime datatype. I know .NET's, I know SQLServer's, but I cannot find anywhere on the internet Crystal reports. Thanks, ...

Computing average values over sections of date/time.

Problem: I have a database of sensor readings with a timestamp for the time the sensor was read. Basically it looks like this: Sensor | Timestamp | Value Now I want to make a graph out of this data and I want to make serveral different graphs. Say I want one for the last day, one for the last week and one for the last month. The reso...

Creating a new .txt file with date in front, C#

Hey all. I am trying to get the following: [today's date]___[textfilename].txt from the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication29 { class Program { static void Main(string[] args) { WriteToF...

How to store into database table two java.sql.Date s, when they are truncated ?

Hello. I want to store into the same table, in different columns 2 java.sql.Date objects to their corresponding SQL Datetime. It works fine, but the hour, minute and seconds are truncated. That's documented in the javadoc. For instance having the date: 5/30/2009 14:33:21 AM when inserted in table it is truncated to 5/30/2009 12:00:00 A...

Fluent NHibernate Composite key with Dates

Hi there. I'm new to NHibernate and am having difficulty with a simple but stuborn error. I have a table in my DB (MSSQL2008) where the composite key is made up of 2 date columns. These would represent a time period StartDate and EndDate that is unique for the purposes of my solution. The table definition is as such: CREATE TABLE [d...

What are good ways in which to specify custom currency, number and datetime formats in GWT?

I have a GWT project in which I need to manually specify currency, number and datetime formats. These customizations include specifying the currency symbols, grouping seperator, decimal seperator, negative number formats etc. What would be the best way to accomplish this? Should I use the GWT NumberFormat class? NumberFormat makes exten...

Saving Dates in SQLServer

hey guys I have a legacy application where the input is a date string, i.e.: 06/12/2009 The format of the input is always a string, and is consistent, it's always dd/mm/yyyy At the moment the legacy app just INSERTS this in a DateTime fields. Obviously if the Localization Culture settings of the Server change, we have a bug. Two...

Where can DATEFORMAT and CONVERT be used? (sql server)

Hi, I am running SQL Server 2005 (express). I am trying to use DATEFORMAT and CONVERT in my queries. I am running into problems, so I first wanted to ask if those functions can be used everywhere. I already know they can be used in SELECT. But can they be used in WHERE as well? For example: SELECT * FROM review AS R, section AS S...

use 'between' with varchar (sql server)

Using SQL Server 2005 Express. ( CONVERT(VARCHAR(8), R.reviewStart, 108) between CONVERT(VARCHAR(8), M.meetingStart, 108) and CONVERT(VARCHAR(8), M.meetingEnd, 108) OR CONVERT(VARCHAR(8), R.reviewEnd, 108) between CONVERT(VARCHAR(8), M.meetingStart, 108) and CONVERT(VARCHAR(8), M.meetingEnd, 108) OR CONVERT(VARCHAR(8), M.meetingStart...

How to update dates stored as varying character formats (PL/SQL)?

Problem: I have a large database table (~500k records) which has a list of dates stored in a varchar2(15) column. These dates are stored in varying formats, ie. some are yyyy-mm-dd, some are mm/dd/yyyy, some are dd/mm/yy, some are mm/dd/yy, etc. Ie: 1994-01-13 01/13/1994 01/13/94 13/01/94 13/01/1994 etc I need to be able to shift thes...

Can I get a list of rows with varchar values that aren't castable to datetime?

I have a legacy SQL Server 2000 database that has one column that has a date that is stored as a varchar instead of a datetime for whatever reason. I want to make a view against this data and use a datetime field instead of a varchar to make making a report against the field easier. The good news is that most of the values look like th...

How do I convert an interval into a number of hours with postgres?

Say I have an interval like 4 days 10:00:00 in postgres. How do I convert that to a number of hours (106 in this case?) Is there a function or should I bite the bullet and do something like extract(days, my_interval) * 24 + extract(hours, my_interval) ...

How to ensure the right DateTime is used?

I have a Silverlight client that talks to some ASP.NET web services, which then modify a database. The client has data that can be modified and sent via the web services to the database. This data is organised by date. Obviously, the client can reside in a different timezone to the ASP.NET server, so, how do I ensure that the DateTime i...

Why would DateTime.Now.Date formats differ between systems?

Why on one system would the default time be 12:00:00 and on another 00:00:00 DateTime.Now.Date Starting with string in a web ui, passing thru Nhibernate to SQL Server 2005. For example 6/10/2009 is entered in a textbox on a web server by the time it is caught in sql profiler I see 2 different times 00:00:00 on my local system (XP), D...

How long is a .NET DateTime/TimeSpan tick?

How long is a .NET DateTime/TimeSpan tick? ...

Next month, same day in PHP

I got a last time (and urgent) requeriment of an "event" that needs to be scheduled the same day of every month. Say of you set the start date on the 1st May you should get the next events on the 1st of Jun, 1 Jul etc. The problem comes with a start date on the 31st (the next ones could be 30 or 28 depending on the month) Considering ...

How do I compare two DateTime objects in PHP 5.2.8?

This seems like something that should be pretty straight forward, but I have been stuck page faulting this problem for a while now, so here goes. Having a look on the PHP documentation , the following two methods of the DateTime object would both seem to solve my problem: DateTime::diff : Get the difference and use that to determine w...