datetime

MySqlConversionException when accessing DateTime field from DataReader

Hello again, I have a C# application over MySql, using MySQL Connector; I'm trying to make a DataReader request, the query executes fine, however, when trying to access a DateTime field, i'm getting MySqlConversionException {"Unable to convert MySQL date/time value to System.DateTime"} this is the prototype if (dr != null && !dr.Read...

How can I stop the time from displaying in a GridView when displaying a date?

I have a web application that I am working on(ASP.NET 2.0 & C#). In it, I have a gridview that gets data from an Oracle Database. Some of the data that I need to display is dates. But when the dates in my gridview show like this: 2009-04-02 00:00:00 I'd prefer they show without the time. I'm using the codebehind to get the data, s...

What's the best way to produce a relative date range (This week, This year, Last month, etc) from a DateTime?

I'm sure I'm not the first person to need to do this, so I'm looking for the best way. I've got a set of radio buttons with choices such as This Year Last Year This Month Last Month This Week Last Week and I need to produce the proper relative date range from the current date (DateTime.Now). For example if Last Year was selected a...

Find 1 year ago from current DateTime

I want to perform this date check: The date entered by the user should not be less than 12 months ago from the current date, e.g. if date_value > '03-apr-2009' How do I write .NET code to do this? ...

How to find day of week in php

I am confused while using php to handle date/time. What i am trying to do is this. When a user visits my page i am asking his timezone and then displaying the 'day of week' in his timezone. I dont want wan to use browser's day. I want to do this calculation in php. This is how i am trying to achieve it. I use 1. The timezone entered...

Date Time Formating

Hi i need to wirte sql query in such a way that it will retrive the date in the following format dd MM yyyy HH mm ss AM(or PM) eg 31 12 2009 12 45 06 AN ...

get date by weekOfYear

Hello, I need Week-Start-Date and Week-End-Date for particular Week number in a year (vb.net or SQL Server) For example, if weeknumber=1 and year 2009, I should get: StartDate=1/1/2009 EndDate=1/3/2009 if weeknumber=2 and year 2009, then: StartDate=1/4/2009 EndDate=1/10/2009 Actually I got week number by using datepart(wk, Date) in...

Unit testing code which gets current time

What is the best way to write unit test for code which gets current time? For example some object might be created only at business days, other objects take into account current time when checking permissions to execute some actions, etc. I guess that I should mock up the Date.today and and Time.now. Is this right approach? Update: Bot...

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...

DateTime hex format

I have the following know pair of hex values and dates: 7D 92 D2 5C = 26/03/2009 - 09:28 7D 92 DA CC = 27/03/2009 - 11:12 7D 92 E3 56 = 28/03/2009 - 13:22 7D 92 EC 4F = 29/03/2009 - 17:15 7D 92 F3 16 = 30/03/2009 - 12:22 7D 92 FB 1A = 31/03/2009 - 12:26 7D 93 0B 01 = 01/04/2009 - 12:01 7D 93 12 88 = 02/04/2009 - 10:08 7D 93 1A 30 = 03/...

How do I store just a date in MS SQL from VB?

My project requires I use VB (5 or 6)* to store a date in an SQL Server database. The SQL datetime type includes the time, which I don't want. I'm also aware that VB's representation of a date doesn't mirror that of SQL Server. So, how can I store a date held in VB's date type in the SQL database, as the datetime at midnight on that dat...

String to mmm-yy format of time in C#

Hi, I need to perform some date operations in ASP.net using C#. The date i would enter should be of format 'Jul-05' (mmm-yy Format and type-string)... how can i check with this???? Or how can i validate this with whatever user is entering as a string??? After validating that, i need to compare tht with a value in Database(say a colu...

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 ...

dateTime object in ASP.NET MVC

Has anyone successfully bound 2 textboxes to one DateTime property using the model binding in MVC, I tried Scott's method http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx but was dissatisfied as this stops the HTML fields and Model properties having the same name (so the validation could not set ...

How do I convert an Excel serial date number to a .NET DateTime?

How do I convert from excel serial date to a .NET date time? For example 39938 is 05/05/2009. ...

Convert UTC to Unix Timestamp

Hi, I'm parsing an RSS feed which has the time and date as UTC, I need to convert this into a unix timestamp. Is there a simple way to do this? ...

How to determine if a date range occurs any time within another date range?

I have an Event table that specifies a date range with start_date and end_date fields. I have another date range, specified in code, that defines the current week as 'week_start' and 'week_end'. I'd like to query all Events for the week. The cases seem to be: Event begins and ends within the week Event begins before the week, but en...

Convert Dates with Mysql

i have a date in this format May 30 2006 12:00AM is there a equivalent of strtotime() in mysql that will let me convert this to a mysql date? ...

Ruby Rails Time.change not working as I would expect...I have checked the docs!

I have a form that contains one date element and 3 time elements. This is because 3 time events will occur on one date, and I don't want the user to have to input that date 3 times. On the server side, I would like to combine the one date with the 3 times to get 3 datetime objects. I was thinking I could just do something like: time_...

Trim first two characters from year of GETDATE()

Hello group, I am trying to create a WHERE clause that says WHERE column_1 = TRIM(LEADING '20' FROM(DATEPART(year, GETDATE()))) Basically column_1 contains the fiscal year but the fiscal year is in the database as 8 or 9 not 2008 or 2009. So I need to figure a way to trim off at least the '20' so that the query will run correctly.....