date

Declare a TDateTime as a Const in Delphi

As far as I know there is no way to do this, but I am going to ask just in case someone else knows how to do this. How can I declare a date as a const in Delphi? The only solution I have found is to use the numeric equivalent, which is kind of a pain to maintain because it is not human readable. const Expire : TDateTime = 39895;...

What's the Postgresql equivalent of string.Format("{0:s}", DateTime.Now) ?

What's the equivalent of sortable datetime/timestamp varchar in PostgreSQL? Console.WriteLine("{0:s}", DateTime.Now); sample format output: 2000-05-04T15:30:59 This works, SELECT now::varchar, output is '2009-03-25', but only for date type, wondering what's the equivalent for timestamp. Note, i know date is sortable in and of itse...

What's the best way to perform math on a floored date in SQL Server?

This is related to Floor a date in SQL server, but I'm taking it one step further: I'm writing a query on a SQL Server table and I want to get all records for the current calendar year and the previous calendar year. So, right now, I'd want a query to return all records between January 1st, 2008 and today. But come January 1st, 2010, I ...

How to combine Dates/Time selected from Dropdowns to use in MySQL Query?

I've got two sets of four dropdowns - startDate,startMonth,startYear,startTime (as 24.00) and the same for endDate/Time - for user to select a start date/time and an end date/time, but don't know how to get the selected values into a datetime format to use in a recordset query using javascript or preferably php(5). I know I need to comb...

How do you obtain the maximum possible date in Oracle?

Is there a function built into Oracle that will return the highest possible date that may be inserted into a date field? ...

Is there a Javascript chart API with date object (labeling) support?

Does anybody know of a Javascript chart API that will handle scaling and labeling for date values on both axes? It looks like I'll have to do manual client-side calculations for labels if I want to use Google Chart API. My data set is potentially sparse in the dates on either axis, so intelligent labeling calculations would save me a bu...

How to determine the number of days in a month in SQL Server?

I need to determine the number of days in a month for a given date in SQL Server. Is there a built-in function? If not, what should I use as the user-defined function? ...

Java 1.5 Calendar#compareTo() confusion

Ok, I'm officially stumped on this one. I have a GregorianCalendar object that I would like to determine if it is in the past, present, or future. So far, the Calendar#compareTo docs are confusing to me, in that I am getting erratic results. A simple test class will illustrate my problem: import java.util.Calendar; import java.util.Greg...

How can I parse a time string containing milliseconds in it with python?

Hi, I am able to parse strings containing date/time with time.strptime >>> import time >>> time.strptime('30/03/09 16:31:32', '%d/%m/%y %H:%M:%S') (2009, 3, 30, 16, 31, 32, 0, 89, -1) How can I parse a time string that contains milliseconds? >>> time.strptime('30/03/09 16:31:32:123', '%d/%m/%y %H:%M:%S') Traceback (most recent call l...

Grails date binding

In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params) What if I have a date field with specific format (e.g. yyyy-MM-dd) from user input? In Spring, we can use registerCustomEditor(). How about Grails? ...

To check weekday of a month

I have a date such as April,1,2009. I want to know what the weekday is, i.e. whether April 1 is a Monday, Tuesday etc. Likewise I want to check weekday of each day in the month of April. ...

How would I compute exactly 30 days into the past with Python (down to the minute)?

In Python, I'm attempting to retrieve the date/time that is exactly 30 days (30*24hrs) into the past. At present, I'm simply doing: >>> import datetime >>> start_date = datetime.date.today() + datetime.timedelta(-30) Which returns a datetime object, but with no time data: >>> start_date.year 2009 >>> start_date.hour Traceback (most r...

SharePoint 2007: Formatting a FormField

Hello, I'm trying to display the page owner and last modified date on the footer of a SharePoint master page for a publishing site. On my master page I currently have: <SharePoint:FormattedString FormatText="Page owner: {0} Last updated: {1:dd/MM/yyyy}" runat="server"> <SharePoint:FormField ControlMode="Display" FieldName="PublishingC...

TSQL -- Inserting Dates Into Dynamic SQL

Consider the following TSQL: SET @WhereClause1 = 'where a.Date > ' + @InvoiceDate I get a date/string conversion error. @InvoiceDate is a datetime variable. What is the right syntax? ...

Most portable SQL date string format

Across various SQL dialects, what string representation for a Date and/or DateTime would be most likely to be interpreted correctly? Is there an SQL Standard? Are the two answers identical or similar? EDIT: For suggestions, can we all please comment with any known SQL dialects that don't comply? ...

Optimal timestamp-based query in Django

What is the optimal query to obtain all the records for one specific day? In my Weather model, 'timestamp' is a standard DateTimeField. I'm currently using start = datetime.datetime(2009, 1, 31) end = start + datetime.timedelta(hours=23, minutes=59, seconds=59) Weather.objects.filter(timestamp__range=(start, end)) but wonder if there...

Date arithmetic in Java

My program is about generating (producing) a Kurosawa and making the customers produce it. Every time we generate a Kurosawa, we have to print its id, its production date and expiration date, which is 3 months from the production date. My problem is: How can I calculate the date after 3 months? Thank you. ...

SQL for counting events by date

I feel like I've seen this question asked before, but neither the SO search nor google is helping me... maybe I just don't know how to phrase the question. I need to count the number of events (in this case, logins) per day over a given time span so that I can make a graph of website usage. The query I have so far is this: select ...

A PostgreSQL timestamp field not formated in the same way when updated with PHP.

I have a timestamp with timezone field in PostgreSQL. When I update this field, I use something like this: $date = date('Y-m-d H:i:s'); Although the SQL works fine, the date saved seem a little bit different to a classic timestamp with timezone date. Example: Default value set to "now()": date 2009-04-06 14:39:53.662522+02 Update ...

How do I convert a date into epoch time in Perl?

Solaris 10 doesn't seem to like me a lot. I am trying to run a simple script to accept date and return epoch of that date: #!/usr/bin/perl -w use strict; use Time::ParseDate; my $date1 = "Mon Mar 27 05:54:08 CDT 2009"; #Convert to seconds since start of epoch my $time1 = parsedate($date1); print $time1; Works perfectly fine on RHEL ...