datetime

RFC-32 Date format to Short Date (MM/DD/YYYY) with ASP Classic

I'm not a strong ASP Classic developer, but I am tasked with supporting this application at work, well I've been trying to convert an RSS feed date to a short date format. And I cannot seem to find a solution. I have this format: Wed, 10 Jun 2009 12:46:13 +0000 and I need to get it into this format: 06/10/2009 So far I have been t...

C# date formatting

Hi there. This is a problem I have come across a number of times and I'm sure there's an elegant solution I'm missing. I have some DateTime variables in c# that I get sent from various SQL tables/websites/web services, often sent as strings. The problem is that some of these sources are set up as English (United States) and some are set...

javascript date subtraction

Hello I am looking for a way to do proper subtraction between two javascript Date objects and get the day delta. This is my approach but it fails for todays date as an input: <script type="text/javascript"> function getDayDelta(incomingYear,incomingMonth,incomingDay){ var incomingDate = new Date(incomingYear,incomingMonth,incomingDay);...

Roundtrip XML Serialization of DateTime and xsd:date?

OK, what am I missing here? MSDN says the following with regard to DateTimeSerializationMode: In versions 2.0 and later of the .Net Framework, with this property set to RoundtripDateTime objects are examined to determine whether they are in the local, UTC or an unspecified time zone, and are serialized in such a way that ...

how to set sql server filed date to mm/dd/yyyy

i cant insert for using c# language DateTime.Now.ToString() insert sqlserver in datatype datetime field ...

Handling international dates in python

I have a date that is either formatted in German for e.g, 2. Okt. 2009 and also perhaps as 2. Oct. 2009 How do I parse this into an ISO datetime (or python datetime)? Solved by using this snippet: for l in locale.locale_alias: worked = False try: locale.setlocale(locale.LC_TIME, l) worked = True exce...

Create template object to display dependent on time of day

I need to create a cross-site template object which will check the current time and return either one string if it's within a time range specified in a model or another or blank in all other cases. Seems simple, but I wonder what is the best approach here? Also, there are a few other considerations: the string should be editable the d...

How do I parse timezones with UTC offsets in Python?

Let's say I have a timezone like "2009-08-18 13:52:54-04". I can parse most of it using a line like this: datetime.strptime(time_string, "%Y-%m-%d %H:%M:%S") However, I can't get the timezone to work. There's a %Z that handles textual timezones ("EST", "UTC", etc) but I don't see anything that can parse "-04". ...

What possible values does datetime.strptime() accept for %Z?

Python's datetime.strptime() is documented as supporting a timezone in the %Z field. So, for example: In [1]: datetime.strptime('2009-08-19 14:20:36 UTC', "%Y-%m-%d %H:%M:%S %Z") Out[1]: datetime.datetime(2009, 8, 19, 14, 20, 36) However, "UTC" seems to be the only timezone I can get it to support: In [2]: datetime.strptime('2009-08-...

how to get the 12 hour date from DateTime

when i get the DateTime.Hour property, i always get the 24 hour time (so 6PM would give me 18). how do i get the "12 hour" time so 6PM just gives me 6. i obviously can do the check myself but i assume there is a built in function for this. ...

How to quickly select DISTINCT dates from a Date/Time field, SQL Server

I am wondering if there is a good-performing query to select distinct dates (ignoring times) from a table with a datetime field in SQL Server. My problem isn't getting the server to actually do this (I've seen this question already, and we had something similar already in place using DISTINCT). The problem is whether there is any trick...

Constructing a DateTime one step at a time.

Hi, I am trying to construct a DateTime in C# one step at a time, as in, the whole date not being in the constructor. I'm not understanding what is wrong though. DateTime d = new DateTime((long)0); d.AddYears(2000); with that d.Years will still be equal to 1 though. Also, I must store the date as a long. So I can't just build the date...

Long to Object implicit converions broken?

I have this code: DateTime d = DateTime.Today; long l = d.ToBinary(); object o = (long)l; d = new DateTime((long)o); When I execute this code, I get an error on d = new Date..(the last line). It says the argument is out of range; that it is out of the range of max and min ticks. Which does seem probable, as using a debugger l is a hug...

JavaScript won't parse GMT Date/Time Format

Hi, I'm trying to get JavaScript to parse a date and time format for me, with the eventual aim of telling me the days passed since that date and the time right now (locally). Unfortunately, the date format I have to work with (it's from a JSON response which I don't have control over) is returning it in 2008-10-01 06:21:43 type format...

Storing items in array by date in PHP

Hi, I am working on a php program that needs to store many "Event" objects in an array. Each event has a "due" date, and I need to be able to easily get these events by that day. There may be more than one event on any given day. I thought about using a MySQL-style date as the key, like $array["year-month-day"], but it's messy. I also ...

Equivalent of __DATE__, __TIME__ macros in C#

Is there an equivalent of __DATE__ and __TIME__ in C#? Basically what I'm trying to do is place some build timestamping in a C# application. One possibility I saw on Microsoft's website was to do the following: Assembly assem = Assembly.GetExecutingAssembly(); Version vers = assem.GetName().Version; DateTime buildDate = new DateTime(...

convert from mysql datetime to coldfusion datetime

Is anyone aware of a simple way to convert mysql datetime values to coldfusion datetime values in CF8 (and it may have to be backwards compatible with CF6)? I need to store date times in mysql and have chosen to store them in mysql datetime format so I can get the db to do date ranges and comparisons for me. I could so this stuff in CF,...

Strange date calculation and test.

Can anyone please explain what the following code checks for? I can make no sense of it, but don't want to leave it out of my rewrite merely out of ignorance. The complete code calculates a variance between now and detailLastDate, i.e. Days(detailLastDate) - Days(Now). For this case, detailLastDate has the value '090722': int num3 = ...

Regular expression for date time format "MM/DD/YY HH:mm:ss AM/PM" in asp.net regular expression validator

Can anyone tell me the regular expression format for "MM/DD/YY HH:mm:ss AM/PM" to use it in a regular expression validator, in asp.net 2.0 ...

How to format a DateTime variable to get the Month, and then put the value into a string in C#? [VS2005]

DateTime dt = Convert.ToDateTime(dateTimePicker1.Text); //taken the DateTime from form string dt1 = String.Format("Y", dt); //trying to make so that it comes to "August 2009" Tried but all I get is dt1="Y". ...