datetime

How to compare DateTime in C#?

I don't want user to give the back date or time. How can I compare if the entered date and time is LESS then the current time? If the current date and Time is 17-Jun-2010 , 12:25 PM , I want user cannot give date before 17 Jun -2010 and time before 12:25 PM. Like my function return false if the time entered by user is 16-Jun-2010 and...

How to represent datetime of different time zomes in C#

I have a .NET WebService (written in C#), that is supposed to serve people around the world. With each request I get the user's datetime in his own time zone with the format : yyyy/MM/dd HH:mm ZZZZ. I have to convert the string to something representing the original date and time and specifying the time zone in GMT. I have to make some l...

DateTime.AddMonths question

Hello, lets say, I have 28th of February 2010 and add one months to this date using AddMonths(1)...the resulting date is 28th of March, but not 31st of March, which I want. Is there a way to tweak that a bit so this works without adding custom code? Edit: I dont need the last day of a month, actually I need to add one month, but when i...

Win32: How to convert string to a date?

In Windows, i want to parse a string as a date using an exact format string. For example, given the string "6/12/2010" and the format: "M/d/yyyy" i want to convert the string to a date, while ensuring that the date matches the format. i also need to be able to specify the Y2K sliding window, pivot. This means that if a 2-digit y...

How to ignore timezone of DateTime in .NET WCF client?

WCF client is receiving a Date value from a Java web service where the date sent to the client in XML is : <sampleDate>2010-05-10+14:00</sampleDate> Now the WCF client receiving this date is in timezone (+08:00) and when the client deserialises the Date value it is converted into the following DateTime value : 2010-05-09 18:00 +08:00...

C# DateTime Class and Datetime in database

Hello . I have the following problem. I have an object with some DateTime properties , and a Table in database that I store all that objects , in Sql server I want to store the DateTime properties in some columns of DateTime Datatype, but the format of datetime in sql server is different from the DateTime class in c# and I got an sql ex...

Javascript, Hour comparisson

Having two strings (start and end time) in such form "16:30", "02:13" I want to compare them and check if the gap is greater than 5 mins. How can this be achieved in Javascript in an easy way? ...

Using MVC2, how do I validate that a date is within a given date range?

I have a requirement, in an MVC2 web application, to validate that the user is at least 13 years old. Is there a date/datetime validation attribute that will enable me to do this? ...

how do i do an insert with DATETIME now inside of SQL server mgmt studio

i have a website that does inserts into this table below. I need to do some manual inserts but i wasn't sure how do pass in the equivalent of DateTime.Now in C#. I am running this below from the query editor in sql server mgmt studio. Is there anyway to pass in the current date time in this query below. INSERT INTO [Business] ...

Django QuerySet next date

My model has a DateField. If I wish to retrive all data that have a date after today, how will it be constructed? Eg. retreive all field with dates after today and stop at 31st december today = datetime.date.today Object.object.filter(date__day != today) or will it be done using exclude? ...

Will this DateTime optimization cause localization problems? Will it be more efficient? Is it worth it?

I'm working on updating a project which uses the following code to place a file in a folder based on the date: int month = DateTime.Now.Month; string zero = (month < 10) ? "-0" : "-"; string folder = "Folder" + DateTime.Now.Year.ToString() + zero + month.ToString() + "\\"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(fo...

Checking if mySql datetime is older then 1 day from php now()

Hi, I have a record returned from MySQL that has a datetime field. What I want to do is take this value and see if it is older then 24 hours, I presume using PHP's time() to get the current time. At the moment if I echo them out I get: 1276954824 this is php's time() 2010-06-19 09:39:23 this is the MySQL datetime I pre...

c# datetime operator +=

i have two variables in type of DateTime, and i want to sum them, how can i do it? i get compilation error that says DateTime dosen't have operator += ...

Date.JS parse isBefore problem

Hi, Im using date.js to compare to dates that are written in user friendly string form(Sat, 1 July 2006 12:34:14). I use this code. function is_new(lasttime, newtime){ lasttime = Date.parse(lastime); newtime = Date.parse(newtime); if(lasttime.isBefore(newtime)){ return true; }else{ return false; } } ...

Core Data NSDate Comparison

I am storing a date attribute in Core Data using the datePicker on the iPhone. I want to then compare the date that matches a certain date using == but I can't get it to work. The greater than and less than seem to working fine though. At first I was storing the date directly from the datePicker which also included the time information...

Find previous calendar day in python

I have a set of files that I'm saving by date, year_month_day.txt format. I need to open the previous day's text file for some processing. How do I find the previous day's date in python? ...

How to set DateTime format in lambda expression?

I am using linq-to-sql joins and group by features to fetch the data I need. I got everything worked but the dateTime format. Here is my code from emp in dc.Employees join lv in (from l in dc.Leaves group l by l.RequestID into le select new { ...

Querying dates in NSPredicate doesn't seem right: not able to match future dates

I have some XML data retrieved from a web service that I use to create NSManagedObjects and store in a sqlite3 backing store. In my app, I'm using NSPredicate objects to query this data by date (along with other fields). The data I have has records for every day from April 2009 through August 2010 (according to the raw XML I retrieved ...

Java/MySQL - datetime problem

Hi, !!IMPORTANT!! Solution found, you need to use a sql.timestamp. Although there are 2 problems with the timestamp. First of all if you want to put an Date into an Timestamp you need to do: new Timestamp(date.getTime().getTime()); Kinda weird... Also the months of a Timestamp start at 0, so january is 0. This means 23-02-2010 in Times...

R time series object with two time dimensions

When you study time series forecast you most often have to deal with two times: the time you issue your forecast and the time you make your forecast for. These two times are not regularly sampled in general. What R object do you suggest to deal with these two times ? please indicate advantages and drawback. If no object exist, how sho...