So I have this list:  [datetime.timedelta(0, 1800), datetime.timedelta(0, 1800), datetime.timedelta(0, 1800), datetime.timedelta(0, 1800)]   Collectively that is 2:00 hours. I'm trying to add those up to get 2:00 time delta, which then in turn needs to be turned into a string of 2.0 Hours. Respectively 1:30 Hours would be 1.5 Hours as the final countdown.
26085
I'm having trouble formatting a datetime.timedelta object.  Here's what I'm trying to do:    I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event.  I would like to display that duration in the format of hours:minutes.  I have tried a variety of methods for doing this and I'm having difficulty.  My current approach is to add methods to the class for my objects that return hours and minutes.  I can get the hours by dividing the timedelta.seconds by 3600 and rounding it. I'm having trouble with getting the remainder seconds and converting that to minutes.  By the way, I'm using Google AppEngine with Django Templates for presentation.
31971
In an extract I am dealing with, I have 2 datetime columns. One column stores the dates and another the times as shown.  How can I query the table to combine these two fields into 1 column of type datetime?  Dates  2009-03-12 00:00:00.000 2009-03-26 00:00:00.000 2009-03-26 00:00:00.000   Times  1899-12-30 12:30:00.000 1899-12-30 10:00:00.000 1899-12-30 10:00:00.000
122443
I need to convert a value which is in a DateTime variable into a varchar variable formatted as yyyy-mm-dd format (without time part). How do I do that?
85002
I have this code in my LaTeX:   \FPset{totalHours}{0}  \newcommand{\entry}[5]{     \FPeval{totalHours}{(totalHours)+#5}     #1 &amp; #2 &amp; #3 &amp; #4 &amp; #5 \\ }   Where \entry is meant to be an entry in a time log. The 5th argument is a number representing the number of hours in that entry. I want to keep a running total of the hours in a variable I can print later on, totalHours.   This seems to do the \FPeval but then totalHours gets reset to 0 by the next time I write \entry. What is the correct way to keep a running total? Thanks.
1637
The Today group has a nice useful total.  However, once 0:00 UTC rolls around, I can no longer see my score for yesterday. Please add a total for the Yesterday and Last 7 days groups.  On a broader note, how can you have a button with an icon of two graphs open a popup that never has any graphs?
49230
I want to write this equation in this way down but I have been unsuccessful. How can I improve this codes in order to get the equation below?  \[ DeltaC{t} = \left\{ \begin{array}{ll}  -1.40- 0.588w_{t-1} - 0.5351\DeltaC_{t-1}+ 0.169\DeltaBC_{t-1} &amp; \mbox{ if $w_{t-1}&lt;- 0.62$} \\ -1.40 - 0.588w_{t-1} - 0.5351\DeltaC_{t-1} + 0.169\DeltaBC_{t-1} &amp; \mbox{$w_{t-1}&gt;0.62$} \end{array} \right. \]
87845
I'm trying to find out how much time it takes to execute a Python statement, so I looked online and found that the standard library provides a module called  that purports to do exactly that:  import timeit  def foo():     # ... contains code I want to time ...  def dotime():     t = timeit.Timer("foo()")     time = t.timeit(1)     print "took %fs\n" % (time,)  dotime()   However, this produces an error:  Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "&lt;stdin&gt;", line 3, in dotime   File "/usr/local/lib/python2.6/timeit.py", line 193, in timeit     timing = self.inner(it, self.timer)   File "&lt;timeit-src&gt;", line 6, in inner NameError: global name 'foo' is not defined   I'm still new to Python and I don't fully understand all the scoping issues it has, but I don't know why this snippet doesn't work. Any thoughts?
68699
Following on from my previous question, , I have now come across a problem regarding the timezone, and it turns out that it's not always going to be "+0200". So when strptime tries to parse it as such, it throws up an exception.  I thought about just chopping off the +0200 with [:-6] or whatever, but is there a real way to do this with strptime?  I am using Python 2.5.2 if it matters.  &gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; fmt = "%a, %d %b %Y %H:%M:%S +0200" &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0200", fmt) datetime.datetime(2008, 7, 22, 8, 17, 41) &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0300", fmt) Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "/usr/lib/python2.5/_strptime.py", line 330, in strptime     (data_string, format)) ValueError: time data did not match format:  data=Tue, 22 Jul 2008 08:17:41 +0300  fmt=%a, %d %b %Y %H:%M:%S +0200
33272
There is this example code, but then it starts talking about millisecond / nanosecond problems.  The same question is on MSDN, .  This is what I've got so far:  public Double CreatedEpoch {   get   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     TimeSpan span = (this.Created.ToLocalTime() - epoch);     return span.TotalSeconds;   }   set   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     this.Created = epoch.AddSeconds(value);   } }
93098
In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year?  Let's say that I have a date of 2008-09-17 12:56:53.430, then the output of flooring should be:   Year:  2008-01-01 00:00:00.000 Month: 2008-09-01 00:00:00.000 Day: 2008-09-17 00:00:00.000 Hour: 2008-09-17 12:00:00.000 Minute: 2008-09-17 12:56:00.000 Second: 2008-09-17 12:56:53.000
63463
I was just wondering, what is the most normal way of interpretating in the last two hours.  If somebody asked you: What have you been doing in the last two hours?  What events from what time period would you mostly cover in your answer if it was already 19:40?     A. I would mention all important things since 17:00 until 19:40(now)   or       B. I would mention all important things since 18:00 until 19:40   (because 40 minutes can be understood as almost hour, but I am not sure if people would count it if it is not full 60 minute hour yet)     C. I would mention all important things since 17:00 until 19:00   Personally, I would go with choice A. But I am not sure if this is the most common way people use it. It might seem that it is almost 3 hours (2h 40m) but so far it is still just 2 hours + some minutes because i would say in the last 3 hours ONLY if 3x60m was completed and would not care if it was more than 3 hours but it still would have to be less than 4 hours.  Does somebody understand me? Which is the most common way of understanding?
34094
I'm designing a website for a client that has some irregular trading hours. Some days they remain open until 2am, others they close at 10pm. They want these hours displayed on their landing page, so visitors can see what time they open &amp; close at a glance. The trouble is I have to work with an API that returns integers only. Based on these integers and the current time, I can display a currently open or currently closed flag accordingly. As it stands currently, this isn't possible. I can't use custom text anywhere, only integers (24 hour time). I'm having some difficulty working out how to display the time. Currently the client displays their hours like this;  Mon 8am - 2am Tue 8am - 2am Wed 8am - 10pm Thu 8am - 2am Fri 8am - 10pm  However I don't think this is correct, and looks quite confusing (what is 8am - 2am?) shouldn't it be;  Mon 8am - 12am &amp; 12am - 2am Tue 8am - 12am &amp; 12am - 2am Wed 8am - 10pm Thu 8am - 12am &amp; 12am - 2am Fri 8am - 10pm  Admittedly, this also looks quite confusing! Any ideas how I can achieve this in the most user friendly way possible, without using custom text?
92574
I looked "$\divideontimes$" up on Google and now I know that it's Unicode U+22c7 but when would it be used?  I am guessing that $5 \divideontimes 5 = 25$ and $1$...?
16732
I'd like to have a time, say 6:45am, and add an amount of hours, say 1.45 hours, to result in another time. So I'd like to add 1.45 hours to 6:45am to get another time.   Is there a command line utile for that? I've done some Googling, and read the man page for date and haven't found anything like that. wcalc doesn't seem to handle time calculations.  EDIT: Mar 6, 2015. This is the script I ended up with to use decimal hours. It could use some error checking to make sure HH:MM uses 2 digits for the hours.  #!/bin/bash # Mar 6, 2015 # Add decimal hours to given time.  # Syntax: timeadd HH:MM HOURS # There MUST be 2 digits for the hours in HH:MM. # Times must be in military time.  # Ex: timeadd 05:51 4.51 # Ex: timeadd 14:12 2.05 echo " " # If we have less than 2 parameters, show instructions and exit. if [ $# -lt 2 ] then     echo "Usage: timeadd HH:MM DECHOURS"     exit 1 fi intime=$1 inhours=$2 # Below is arithmetic expansion $(()) # The bc calculator is standard on Ubuntu.  # Below rounds to the minute.  inminutes=$(echo "scale=0; ((($inhours * 60)*10)+5)/10" | bc) echo "inminutes=$inminutes" now=$(date -d "$intime today + $inminutes minutes" +'%H:%M') echo "New time is $now"
113519
I'm having a save method with several Conditions in it.Here is my apex class  invoiceset = [select SiteUrl__c, Prefix__c,Seperator__c,Seperator1__c,DateValue__c,DateValue1__c,Date_Format__c,Incrementer__c,Counter_Val1__c,counter__c from Invoice_setting__c limit 1];        if(invoiceSet[0].DateValue__c == 'Date' &amp;&amp; invoiceSet[0].DateValue1__c == 'Date'){         if(invoiceSet[0].Date_Format__c == 'dd-mm-yyyy'){              datenow = DateTime.now().format('dd-MM-yyyy');                   }else if(invoiceSet[0].Date_Format__c == 'MM-dd-yyyy'){              datenow = DateTime.now().format('MM-dd-yyyy');                     }else if(invoiceSet[0].Date_Format__c == 'dd/MM/yyyy'){              datenow = DateTime.now().format('dd/MM/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'mm/dd/yyyy'){              datenow = DateTime.now().format('mm/dd/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'yy'){              datenow = DateTime.now().format('yy');          }else if(invoiceSet[0].Date_Format__c == 'yyyy'){              datenow = DateTime.now().format('yyyy');          }           prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + datenow + invoiceset[0].Seperator1__c + datenow;       }      else if(invoiceSet[0].DateValue__c == 'Counter' &amp;&amp; invoiceSet[0].DateValue1__c == 'Counter'){       if(invoiceSet[0].counter_val1__c == null){          invoiceSet[0].Counter_Val1__c = invoiceset[0].Counter__c;        }else if(invoiceSet[0].Counter_Val1__c == invoiceset[0].Counter__c){            intt = integer.valueof(invoiceSet[0].Counter__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }else {             intt = integer.valueof(invoiceSet[0].Counter_Val1__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }        update invoiceset;         prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + invoiceSet[0].Counter_Val1__c + invoiceset[0].Seperator1__c +invoiceset[0].Counter_Val1__c;       } &amp;&amp; so on........   Inorder to cover all this conditions should I write those many methods or any other easy way?  Here is my Test Code  public static testmethod void test(){    invoice_setting__c setng = new invoice_setting__c(Name='Invoice Settings',SiteUrl__c='www.google.com',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Date',Seperator1__c = '/',dateValue1__c = 'Date',date_format__c='dd-mm-yyyy');     insert setng; } public static testmethod void test1(){     invoice_setting__c setng1 = new invoice_setting__c(Name='Invoice Settings',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Counter',Seperator1__c = '/',Counter_Val1__c=null,dateValue1__c = 'Counter',date_format__c='dd-mm-yyyy',Incrementer__c='10');     insert setng1; } &amp; so on......   Any Suggestions for this please
102384
I am still not able to get the correct difference, really struggling to make it working. The business hour set from 10 AM to 7 PM  BusinessHours bh = [SELECT FridayEndTime,FridayStartTime,Id,MondayEndTime,MondayStartTime,                     FROM BusinessHours where Name='Test Business Hour'                     LIMIT 1]; Time startTime = bh.MondayStartTime;        Time endTime = bh.MondayEndTime;  Date d = Date.today(); Datetime monTodaystart = Datetime.newInstance(d.year(),d.month(),d.day(),startTime.hour(), startTime.minute(),startTime.second()); Datetime monTodayend = Datetime.newInstance(d.year(),d.month(),d.day(),endTime.hour(), endTime.minute(),endTime.second()); System.debug('monTodaystart :: '+monTodaystart);     System.debug('monTodayend :: '+monTodayend);   Long diff = BusinessHours.diff(bh.Id, monTodaystart, monTodayend); System.debug('diff  :: '+diff);   I tried this simple example, but still its not working why ? How we can manipulate it ?  Datetime monTodaystart = Datetime.newInstance(2017,8,20,10,0,0); Datetime monTodayEnd = Datetime.newInstance(2017,8,20,17,0,0); System.debug('ID : '+bh.Id);  Long diff = BusinessHours.diff(bh.Id, monTodaystart,monTodayEnd); System.debug('diff  :: '+diff);   I dont think I should used the API here, instead I should use my custom logic, looks like some bug in the API still exists.
32919
I'm trying to parse an international datetime string similar to:  24-okt-08 21:09:06 CEST   So far I've got something like:  CultureInfo culture = CultureInfo.CreateSpecificCulture("nl-BE"); DateTime dt = DateTime.ParseExact("24-okt-08 21:09:06 CEST",     "dd-MMM-yy HH:mm:ss ...", culture);   The problem is what should I use for the '...' in the format string? Looking at the  MSDN page doesn't seem to list a format string for parsing timezones in PST/CEST/GMT/UTC form.