datetime

Match parts of any date anywhere in a string using regex

This has probably been answered dozens of times, couldn't find the answer though... Anyway, working in a Smalltalk environment I have a string composed of three parts like this: "ttm 4/6/97 00:08". The string is very variable, meaning some part may be missing (so it would be a string composed of less then three parts like "ttm 4/6/97") ...

How to create a DateTime object not in the current culture

I'm really drawing a blank on this one. I've been working on globalization but the DateTime seems to always revert back to the CurrentThread's culture. I broke this down into smaller steps hoping to find my issue, but it's starting to drive me crazy. I've got a textbox with the date expressed as a string: // the CurrentThre...

Generating UTC Time in java

I want to get the UTC time for 01/01/2100 in Java to '2100-01-01 00:00:00'. I am getting "2100-01-01 00:08:00". Any idea, how to correct this. public Date getFinalTime() { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date finalTime = null; tr...

Detecting changes to system time in JavaScript

How can I write a script to detect when a user changes their system time in JS? ...

Datetime format help

Hi all... I want only Hr and Min in time format so i did select convert(varchar(20),GETDATE(),108) ===>> output is "12:57:54" but i want only "12:57" this much so how i will do that in sql server ...

using Nullable DateTime in C#

I wanted to assign null value to DateTime type in c#, so I used: public DateTime? LockTime; When LockTime is not assigned LockTime.Value contains null by default. I want to be able to change LockTime.Value to null after it has been assigned other value. ...

Formatting a Datetime returned from a SQL UD Function

Consider this simple user defined function: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER FUNCTION [dbo].[ufn_GetFirstDayOfMonth] ( @pInputDate DATETIME ) RETURNS DATETIME BEGIN RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' + CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/01' AS DATETIME) END whi...

how to subtract two dates and times to get difference

i have to sent an email when a user register email contain a link that is become invalid after six hours what i m doing when email is sent i update the db with field emailSentDate of type "datetime" now i got the curent date and time and has made to the same formate as it is in db now i want to find that both these dates and time have di...

Way to query database with SQLAlchemy where a date is a particular day of the week?

I have a table (called 'entry') which has a datetime column (called 'access_date'), and I want to do an SQLAlchemy query that only produces results where entry.access_date is a Monday (or any other day of the week specified by a number [0..6]). Is this possible? I am using sqlite & SQLalchemy 0.5.8 if that makes any difference. ...

In PHP, if a variable holds a datetime, what does operator-- do?

My background is C, Java, C#, and VB.NET, but I have to work on some basic PHP stuff. I've gotten to this line of code: if($flag) $event_end--; What exactly is being decremented? The raw ticks? $flag (I think) represents if the event is an all-day event, where the start would be 7/1/2010 and end would be 7/2/2010. Does the -- esse...

How to insert date and time with fractional seconds in Oracle?

I'm using oracle 11g. I'm inserting date and time using function SYSDATE into column with type TIMESTAMP. But fractional seconds always are 0. How can I insert date and time of database server with fractional seconds? Is there any functions? ...

Converting a custom date format (string) to a datetime

I have a large set (100+ million) of observations with the date represented as a custom string format. We did not generate the date strings, I just need to convert the date string to a datetime type. How do I convert a string date (eg, 12 JUN 2010) to a datetime? My thoughts are to parse the string into components, assemble them in the...

Using custom sql in Django

Is there a way to run a custum SQL statement in Django? I have some timestamp fields in my database that have timezone information. Normally you could just enter the time in a format like: 2010-7-30 15:11:22 EDT and in my case postgresql will figure it out. But in Django it treats timestamps as Datetimes which don't store timezone inform...

date from string help. I can convert to the string I want, but I can't convert back.

I have a string I need to convert back to a date. I can call .ToString("yyyyMMdd") and get the string i want. My question is how can I convert that back into a date? I'm trying something like the following with no luck. DateTime d; var formatInfo = new DateTimeFormatInfo {ShortDatePattern = "yyyyMMdd"}; if (DateTime.TryParse(details.Det...

mySql sum a column and return only entries with and entry in last 10 minutes

heres a table, the time when the query runs i.e now is 2010-07-30 22:41:14 number | person | timestamp 45 mike 2008-02-15 15:31:14 56 mike 2008-02-15 15:30:56 67 mike 2008-02-17 13:31:14 34 mike 2010-07-30 22:31:14 56 bob 2009-07-30 22:37:14 67 bob 2009-07-30 22:37:14 22 ...

Date::ICal mystery (hour does not return the correct value

Here's the code: $ical = Date::ICal->new( year => 1964, month => 10, day => 16, hour => 20, min => 12, sec => 47, #tz => '0530' ); ok( defined $ical, 'new() returned something' ); ok( $ical->isa('Date::ICal'), " and it's the right class" );...

What is the name of this technique?

I just finished writing a date parser for my ECMAScript implementation. Previously I had written a regular expressions compiler and I was really impressed with the way the spec described the process. Essentially the input is passed through a series of continuations that test each portion of the string. My date parser is loosely based aro...

GridView cell Date Format

I want to format Date of the GridView Cell text like ddMMMYYYY (i.e) 07MAY2010 how to achieve this? RowDataBound() { .... e.Row.Cells[10].Text = ......? } ...

DATE_FORMAT() in MySQL query

I'm trying to change this timestamp 2010-08-02 00:28:20 to month/day/year - 08/02/10 ..in the query (I know that doing it in the query is faster). $sql = "SELECT * FROM posts ORDER BY post_date DESC"; I tried using the DATE_FORMAT() in the query many ways but I can't seem to get it right.. Can someone please share how to ...

distance_of_time_in_words gone crazy!

distance_of_time_in_words(strtotime(2010-08-07), strtotime(2010-08-01)) returns '6 minutes' $a = '2010-08-02 00:39:29' $b = '2010-08-01' distance_of_time_in_words($a, $b) returns 'less than a minute' $a = '2010-08-02 00:39:29' $b = '2010-08-01 20:08:00' distance_of_time_in_words($a, $b) returns 'less than a minute' I wonder if I...