I'm trying to convert a string "20091229050936" into "05:09 29 December 2009 (UTC)"
>>>import time
>>>s = time.strptime("20091229050936", "%Y%m%d%H%M%S")
>>>print s.strftime('%H:%M %d %B %Y (UTC)')
gives
AttributeError: 'time.struct_time' object has no attribute 'strftime'
clearly, I've made a mistake: time is wrong, it's a datetime ...
I need to match on a date using the LIKE operator. The date should be in current user's local format, not in the general format.
So I use the strftime function like this:
WHERE strftime('%d.%m.%Y %H:%M', createdDate, 'localtime') LIKE '%{searchTerm}%'
Unfortunately this works only for fixed format '%d.%m.%Y %H:%M'. But I want to use ...
How to determine dates by number of days from now - "What date is 180 days from now?"
...
I have a table that has two time columns. One is a login time one is a logout time. I would like to be able to filter between the two, basically greater than the minimum selected and less than the maximum selected. I am using a monthly calendar to get me the spans of time but it is not working correctly. From there I would like to add th...
I'm using two LINQ queries to access my database using Entity Framework:
The first stores a token in the database and gives it a 60 second timeout:
string tokenHash = GetTokenHash();
Token token = new Token()
{
Client = client,
Expiry = DateTime.Now.AddSeconds(60),
UserId = userId,
TokenHash = tokenHash,
};
context.AddT...
How Can I Turn This DateTime value into something that Sql Server 2005 won't shout at me for.
2007-12-01T00:00:00+00:00
(All I care about is the date, NOT the time).
I get this error when I tried to pass this argument to my stored procedure as a DateTime variable (Both the C# object and the Sql Server object are DateTime variables and...
I want to check if a date has a correct format. There is many possibilities of correct dates like:
02.08.2010
2.8.2010
02.8.2010 02.08
02.August
...
I can test each on with code like this:
if (DateTime.TryParse(DateTime.ParseExact(date, "dd.M.",
new CultureInfo("sl-SI")).ToString(), out dt))
But then...
I have a string like this:
"20090212"
and I want to convert to valid C# datetime.
Do I need to parse it out because that seems too much work?
...
I am trying to use the selectionstart and selectionend attributes from monthcalendar to filter between two login dates in a table. When I chose one single day, this does not work correctly. If i chose the day before and the day after the day in question then it will. The time values in my DB are like this:
2/23/2010 11:17:01 AM
Both ...
I'd like to time a block of code without putting it in a separate function. for example:
def myfunc:
# some code here
t1 = time.time()
# block of code to time here
t2 = time.time()
print "Code took %s seconds." %(str(t2-t1))
however, I'd like to do this with the timeit module in a cleaner way, but I don't want to make a sepa...
I'm trying to parse Rss2, Atom feeds using SyndicationFeedFormatter and SyndicationFeed objects. But I'm getting XmlExceptions while parsing DateTime field like pubDate and/or lastBuildDate.
Wed, 24 Feb 2010 18:56:04 GMT+00:00 does not work
Wed, 24 Feb 2010 18:56:04 GMT works
So, it's throwing due to the timezone field.
As a ...
I have a MaskedTextBox that has the mask 00/00/\2\000 (restricting input to XX/XX/20XX) and DateTime values with a single digit month or day recently started displaying incorrectly. The MaskedTextBox.Text property is bound to BindingSource.SomeProperty (of type DateTime.)
I know that at some level of data-binding the ToString method is...
I am trying to convert a date/time GMT 0 to GMT -6 in Perl.
For example, a DHCP Server lease time is in the following format:
2010/02/18 23:48:37
I am trying to convert that time to the Localtime zone (GMT -6) but need it to honor Daylight savings time.
The script below may be overkill, but I am not sure how to proceed from here...
What I am trying to do is I have a selected date formatted as below:
$selectedDate = 2010/02/24
I want to check it is both todays date and it is past 9pm on the server and set a value if it is.
I can get a time by using the following:
$checkTime = date("H:i");
I want to create something like:
if ($checkTime > 21:00 && $selectedD...
datetime.datetime.utcnow()
datetime.datetime(2010, 2, 25, 4, 14, 37, 366086)
Why does this datetime not have any tz info say its a utc date.
...
Hi,
I have a database that stores dates broken into int's. I.e. Day, Month and Year are stored separately in different columns.
In existing SQL queries, the method used is:
DATEADD(dd, - 1, DATEADD(mm, Z.LastMonth, DATEADD(yy, Z.LastYear - 1900, 0))) AS last_date
I cannot change the database to store dates instead.
Looking further i...
[MySQL/PHP] My table has a date column of datetime format. All records are of the YYYY-MM-DD HH:MM:SS variety.
MySQL queries like SELECT record FROM table WHERE date > '1941' AND date < '1945' work nicely.
MySQL queries like SELECT record FROM table WHERE date > '1941-03-01' AND date < '1945-01-30' also work nicely.
But what about if ...
How can I convert a date time string of the form Feb 25 2010, 16:19:20 CET to the unix epoch?
Currently my best approach is to use time.strptime() is this:
def to_unixepoch(s):
# ignore the time zone in strptime
a = s.split()
b = time.strptime(" ".join(a[:-1]) + " UTC", "%b %d %Y, %H:%M:%S %Z")
# this puts the time_tupl...
I am in a C#/ASP.NET environment.
I have a web app that has a series of users logged in - and I have a master user who needs to know the last time all other logged in users went to a page (i.e. makes a Http request). I am able to get a listing of all the users through a set of session variables through the Application variable - but I a...
Hi everyone,
I'm trying to perform date manipulations using JavaScript on a single line, and I'm having problems with the year (not the month or day). I got the idea from this link. Am I missing something?
The code is as follows:
var newyear = new Date((new Date()).getYear(), (new Date()).getMonth(), (new Date()).getDate()+5).getFullYe...