datetime

Get AM/PM for a date time in lowercase using only a datetime format

I'm to get a custom DateTime format including the AM/PM designator, but I want the "AM" or "PM" to be lowercase without making the rest of of the characters lowercase. Is this possible using a single format and without using a regex? Here's what I've got right now: item.PostedOn.ToString("dddd, MMMM d, yyyy a\\t h:mmtt") An example ...

Python's timedelta: can't I just get in whatever time unit I want the value of the entire difference?

I am trying to have some clever dates since a post has been made on my site ("seconds since, hours since, weeks since, etc..") and I'm using datetime.timedelta difference between utcnow and utc dated stored in the database for a post. Looks like, according to the docs, I have to use the days attribute AND the seconds attribute, to get t...

Format a date in XML via XSLT

When I use the XML serializer to serialize a DateTime, it is written in the following format: 2007-11-14T12:01:00 When passing this through an XSLT stylesheet to output HTML, how can I format this? In most cases I just need the date, and when I need the time I of course don't want the "funny T" in there. ...

format date in c#

hi how can i format date ? dd/mm/yyyy or mm/dd/yy like in VB format("dd/mm/yy",now) how can i do it in c# thank's ...

C# - What is the best way to get a list of the weeks in a month, given a starting weekday?

I need to get a list of weeks for a given month, with Monday as the start day. So for example, for the month of February 2009, this method would return: 2/2/2009 2/9/2009 2/16/2009 2/23/2009 ...

Convert Dates

Hi, Does anyone know of an easy(built in) way to convert a string like '20081231T130000' (ICalendar I think) to DateTime in C#? Or do I need to parse the string? ...

How to trim datetime string to its minute in GridView?

I have bound fields in GridView to some dateTime property of data objects. The fields are displayed to the seconds level. It looks like 2009-2-3 18:00:00 PM. I just want it displayed to the minutes. E.g 2009-2-3 18:00. What is the best way to do this? Edit: I find use DataFormatString="{0:g}" is fine for me. The format is 2009-2-3...

JPA/Hibernate store date in UTC time zone

How can I configure JPA/Hibernate to store a date/time in the database as UTC (GMT) time zone? Consider this annotated JPA entity: public class Event { @Id public int id; @Temporal(TemporalType.TIMESTAMP) public java.util.Date date; } If the date is 2008-Feb-03 9:30am Pacific Standard Time (PST), then I want the UTC t...

Python time to age

I'm trying to convert a date string into an age. The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is. I have sucessfully converted the date using: >>> time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200") (2008, 11, 17, 1, 45, 32, 0, 322, -1) For some reason %...

MySQL Query GROUP BY day / month / year

Heyall, Is it possible I make a simple query to count how many records I have in a determined period of time like a Year, month or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE record_date.YEAR = 2009 GROUP BY record_date.YEAR Or even: SELECT COUNT(id) FROM stats GROUP BY record_date.YEAR, record_date.MONTH...

Best way to compute UTC/local datetime conversion in a WCF client/server application

I've got a client/server application, written in WCF / C#3.5. The server is in my local TimeZone, and clients are spreaded accross the world. My current strategy is to use UTC DateTime everywhere on the server and in the database, and to let the clients handle correctly the UTC DateTimes they receive. This means that everytime the cli...

Best way to store old dates in SQL Server

What is the best/most efficient way to store old dates (pre-1753) in SQL Server 2005? I am not concerned with storing times - just dates. SQL Server's datetime data type can only hold dates back to January 1, 1753. The MSDN documentation states that there are date and datetime2 data types, but SQL Server Management Studio does not seem t...

Various Python datetime issues

I have two methods that I'm using as custom tags in a template engine: # Renders a <select> form field def select_field(options, selected_item, field_name): options = [(str(v),str(v)) for v in options] html = ['<select name="%s">' % field_name] for k,v in options: tmp = '<option ' if k == selected_item: tmp +...

SQL generating a set of dates

I am trying to find a way to have a SELECT statement return the set of dates between 2 input dates with a given interval. I would like to be able to easily change the time frame and interval that would be returned, so hard coding something with a series of SELECT ... UNIONs would not be ideal. For example: I want all the dates at 5 sec...

Time/Date range grammars

I need to parse strings containing time spans such as: Thursday 6:30-7:30 AM December 30, 2009 - January 1, 2010 1/15/09, 7:30 to 8:30 PM Thursday, from 6:30 to 7:30 AM and others... added 6:30 to 7:30 and date/times such as most any cases that Word's insert->date can generate As I'd be extremely surprised if anything out there ...

Best way to handle storing/displaying dates in different timezones in PHP?

I've been reading up on this topic for the past few hours, and I think I've got a handle on it, but I'd like some confirmation. Situation I want a user in, say, California to be able to post a comment that will be stored in MySQL. I then want a user in, say, Texas to be able to view the comment with the post date adjusted to his or her...

Datetime type

i have store this kind of datetime: 06.09.2009 12:30:45 . i have been using xml datastore type. i set "06.09.2009 12:30:45" in xml file . "06.09.2009 12:30:45" is there datatype? or Datetime type? ...

StringFomat Localization problem

Hi In WPF 3.5SP1 i use the last feature StringFormat in DataBindings: <TextBlock Text="{Binding Path=Model.SelectedNoteBook.OriginalDate, StringFormat='f'}" FontSize="20" TextTrimming="CharacterEllipsis" /> The problem i face is that the date is always formated in...

Learning Days C#

How can i learn next wednesday, monday in a week? Forexample Today 06.02.2009 next Monday 09.02.2009 or wednesday 11.02.2009 there is any algorithm? i need : which day monday in comingweek? findDay("Monday") it must return 09.02.2009 ===================================================== findDay("Tuesday") it must return 10.02.200...

How to refresh xml cache after one day from the last modified date??

Hi, I am developing a web app using ASP.NET 2.0 (C#), where on home page I am displaying recently added records. Adding of records frequency is around 1-5 records per day, so I decided not to put much overhead on the sql server by fetching recent records every time from db server. So, To make the data cached I have used XML files, I h...