datetime

Nullable Types as Property

Is it ok to construct my object entities with this type? public class Patient { public Datetime? AdmissionDate { get; set; } public double? AdmissionFee { get; set } public int? RoomNumber { get; set } } WHat is the drawback if I implemented this in all my entities, because recently, I always encounte...

How to compare dates in Django

I would like to compare a date to the current date in Django, preferably in the template, but it is also possible to do before rendering the template. If the date has already passed, I want to say "In the past" while if it is in the future, I want to give the date. I was hoping one could do something like this: {% if listing.date <= no...

PHP Turn back time

Hello, I would like to turn back the time 10 seconds before current time and output in this format date('H/i/s') How can I do this ? I dont want to get current time then remove 10 seconds from time . Thanks ...

How to write "First of every month in Ruby"

I'm trying to write an iterator in ruby that sends a callback on the first of every month. How would you write something like that? ...

Store UTC date time in database

I will convert all date & time input by user (local time) to UTC and store it in database. When display back I will convert UTC time to their time zone which is set in their profile. Is it good? ...

Exception using DateTime in a parameterized OleDbCommand

I'm trying to insert a System.DateTime into an Access database using a parameterized OleDbCommand in C#. However, it throws a Data type mismatch in criteria expression exception. Here is my code: string statement = "INSERT INTO Log (SCTID, LogDateTime, Type, Message, Visible)" + "VALUES (?, ?, ?, ?, ?);"; OleDbCommand insertComman...

how to calculate the other country time. using my local machine time in c#?

how to calculate the other country time. using my local machine time in c#? Example: My system having India time and my array contains all the countries GMT time. How to do the calculation to get the other country time? if my time is 5.00 P.M if the country is Pakistan it should show 4.30 p.m ...

[php] Opening app to world market. How to quickly allow for timezones and date/number handling

Hey Guys, What is the quickest way to internationalise a php webapp? We need to be able to change all times & dates based on a timezone selected by a user... [edit: this application is already in production. I've been given the task of making it usable on an international level asap.] ...

Evaluate whether date is not one of past dates in model -- Ruby on Rails

I have a Day model which has a date column. I have to implement the validation that the date column must not have a past date. If the date is a past date it must not get saved to the database and give the appropriate error message right on the. I know I can put this validation in the controller, but I think it violates the MVC rules i.e ...

How to show datapicker for datatype in asp.net MVC2 using telerik in edit mode

Hi.. I have an MVC application and using telerik grid for performing the listing,add,edit operation.I am using popup mode for edit/add .I want to show the datepicker for date datatype in the edit and add operation. I have created a partial view for the datepicker using telerik as: <%@ Control Language="C#" Inherits="System...

Convert epoch to date in sqlplus / Oracle

Hi, I have the following table: SQL> desc recording Name Null? Type -------------------- -------- ------ CAPTUREID NOT NULL NUMBER(9) STARTDATE NOT NULL DATE ENDDATE DATE STATE NUMBER(1) ESTIMATEDENDTIME NUMBER(13) Here's a sing...

Mysql DATETIME related queries: how to calculate the expired entry?

i have a table that has a cell containing a timestamp when the entry was created, than i have a cell containing the number of days that row should expire, something like this my_tb: id | elem1 | timestamp | maxdays | active 1 | jondoe | 2010-09-28 | 60 | 1 1 | foo | 2010-09-18 | 30 | ...

Linq2EF: Return DateTime with a TimeZone Offset

Our database has all times stored as UTC, and we know the user's current timezone, so want to return it relative to that. So we want to incorporate the offset in a LINQ projection as so: var users = from u in this.Context.Users select new UserWithCorrectedDate { Id = u.Id, FirstNam...

Differring behaviour of Date.parse?

alert(Date.parse('Mar 1 1990')); in jsFiddle, this returns a datetime integer, as expected. On my machine, it returns... a timestamp string? Thu Mar 01 1990 00:00:00 GMT-0500 (EST) vs 636267600000 ...

SQL Server function to return minimum date (January 1, 1753)

I am looking for a SQL Server function to return the minimum value for datetime, namely January 1, 1753. I'd rather not hardcode that date value into my script. Does anything like that exist? (For comparison, in C#, I could just do DateTime.MinValue) Or would I have to write this myself? I am using Microsoft SQL Server 2008 Express. ...

Regular Expression to validate short and long date in mm/dd/yyyy format in javascript

Hi all, I wanna validate date which can be either in short date format or long date format. eg: for some of the valid date. 12/05/2010 , 12/05/10 , 12-05-10, 12-05-2010 var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/; var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/; var valid = (reLong.test(entry)) || (reShort.test(entry)); if(valid...

Convert a free text into an array of dates - Universal analysis matcher

Here's a big challenge... something not easy to do with clean code (though that's not really necessary). I have two strings, one a list of dates, one of times. The time can be on the first string. The format is unpredictable, but if it can meet the samples below, it would cover 90% of cases. Input date format is DD/MM public void Test(...

SQL Server does not use an index comparing datetime to not null

Hello, I have a simple table not related to any other. It has a not PK column that it is a date. I have created a non-clustered index to that column. If I make this query: select * from table where datecolumn is not null <-- does not use the index and goes really slow. But if I remove the not, this way: select * from table where datec...

Zend Date giving me zeroes, why?

More problems with dates. Basically I'm trying to populate a table with some datetime values from Zend. The datatype of the column that I'm trying to populate is 'datetime'. However, no matter which constant I try the column is always populated with zeroes. I've tried Zend_Date::ISO_8601, Zend_Date::DATETIME, Zend_Date::now() to no avai...

javascript: get current date/time in seconds?

Hi there, Can anyone inform me of the best way to get the current date/time in seconds in javascript? ...