datetime

How can i put just the date from a dateTimePicker into a variable?

Hi, I’m using C# and WinForms to try and put just the date from a dateTimePicker into a variable. But I keep getting the date and the time. In the example below textBox1 shows what I’m looking for. But I can’t figure out how to do the same for textBox2. Where it gives the date and time. This isn’t the exact code I’m using in my app, but ...

What is the easiest way to handle dates/times in Python?

My use case is that I'm just making a website that I want people all over the world to be able to use, and I want to be able to say things like "This happened at 5:33pm on October 5" and also "This happened 5 minutes ago," etc. Should I use the datetime module? Or just strftime? Or something fancier that isn't part of the std distro of...

Why is this code giving me a date 39k years in the future?

I've written a method that returns the milisecond value of a string formatted date, and for some reason it's giving me dates 39000 years in the future. any ideas why? private long getTimeInMs(String currentStartTimeString) { //String newDateString = currentStartTimeString.substring(6,10)+"-"+currentStartTimeString.substring(3, 5)+"...

What can cause "The conversion of a char data type to a datetime data type resulted in an out-of-range"?

I am running into an error I am having trouble figuring out. I have 2 tables and I'm trying to copy data from one to the other (simplified view): MyTable ------- ID varchar(11) do not allow nulls Field01 numeric(6,0) allow nulls MyTable_Temp ------------ ID varchar(11) do not allow nulls Field01 numeric(6,0) allow nulls My query loo...

How to parse dates with -0400 timezone string in python?

I have a date string of the form '2009/05/13 19:19:30 -0400'. It seems that previous versions of python may have supported a %z format tag in strptime for the trailing timezone specification, but 2.6.x seems to have removed that. What's the right way to parse this string into a datetime object? ...

Date time picker

I am developing a C# application where user can select any date time format and display in date time picker.How to change the format of date time picker in code? ...

Microsoft Access SQL Date Comparison

I am using Access 2007. I need to return rows with a date/time field falling within a date range to be specified in query parameters. The following doesn't error out, but doesn't appear to work. SELECT FIELDS FROM FOO WHERE (FOO.CREATED_DTG BETWEEN [START_DTG] And [END_DTG]); Likewise this doesn't work for me SELECT FIELDS FROM FOO...

How can I create relative/approximate dates in Perl?

I'd like to know if there are any libraries (preferably DateTime-esque) that can take a normal date time and create an appropriate relative human readable date. Essentially the exact opposite of the more common question: How can I parse relative dates with Perl?. Obviously, the exact wording/interpretation is up to the actual implementa...

How to get GPS Time on Windows Mobile 6?

Hi, How can I get the time that is not based on my PC time? I use the code below to get time and it works, but when I change my computer time, the time is no longer correct, so is there a way that I can get the actual real time but not from PC time? Maybe GPS time? private void btn_DateTime_Click(object sender, EventArgs e) {...

Retrieving a DateTime value from a DataRow (C#)

How can I get DateTime value in C# from row, the current code is giving me error any help is appreciated, the data is coming in from progress database: foreach (DataRow r in ds.Tables[0].Rows) { string prodCode = r["PRD-CDE"].ToString(); statCode = r["STAT"].ToString(); DateTime firstIssueDate = (DateTime)(r["FISS"]); D...

Monitor the Date in Flex for a change

In Flex/ActionScript 3, is there a better way to monitor the date/time to determine if the date has changed to the next day by creating a timer that dispatches every minute? ...

Ordering nullable DateTime in Linq to SQL

I have started using Linq to SQL for a project im working on and i have run into a problem when ordering by a DateTime field but since the DateTime allows nulls the nulls are coming up as less than the actual dates in there. So i pretty much want the ones with a date to be at the top (ordered either way) then all the ones with no date s...

How do I read a date in Excel format in Python?

How can I convert an Excel date (in a number format) to a proper date in Python? ...

C#: Making sure DateTime.Now returns a GMT + 1 time

I am using DateTime.Now to show something according to today's date, and when working locally (Malta, Europe) the times appear correctly (obviously because of the Time Zone) but ofcourse when I upload it to my hosting server (USA), DateTime.Now does not represent the correct time zone. Therefore, in my code, how can I convert DateTime.N...

Transform DateTime into simple Date in Ruby on Rails

I have a datetime column in db that I want to transform into a simple date when I show it to users. How can I do that? def shown_date # to_date does not exist, but is what I am looking for self.date || self.exif_date_time_original.to_date end ...

Get Day of Week in SQL 2005/2008

Say I have a date 01/01/2009, I want to find out what day it was e.g. Monday, Tuesday, etc... Is there a built in function for this in Sql2005/2008? Or do I need to use an auxiliary table? ...

Get TZ information of the system in Python?

I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process. ...

Calculate years from date

I'm looking for a function that calculates years from a date in format: 0000-00-00. Found this function, but it wont work. // Calculate the age from a given birth date // Example: GetAge("1986-06-18"); function getAge($Birthdate) { // Explode the date into meaningful variables list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $B...

Java - Working with Date/Time in J2ME

(1) How to extract time portion from a Date-object and use it as a String in J2ME? (2) How to convert that time-string back to Date - object in J2ME? I have done something to achieve this, but it is not showing correct-time. ...

Best practice for storing the date in MySQL from PHP

I've been using the unix timestamp all my life. I like it because it's easy to compare, it's fast because I store it as an integer. And since I'm using PHP, I can get any date/time format with date() function from the unixtimestamp. Now, some people are saying that it's best to use the DATETIME format. But besides the more suited name,...