In a datetime object I would like to change days and hours.
Or in other words, I would like to copy this datetime object but
increase days and hours.
Is it possible?
For example:If I have a datetime object like this
datetime.datetime(2006, 8, 3, 14, 13, 56, 609000)
I would like to make a new ,for example like this
datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)
is it possible to do so?
Thank you
L 4 6873
In <11*********************@p79g2000cwp.googlegroups. com>, Lad wrote:
In a datetime object I would like to change days and hours.
Or in other words, I would like to copy this datetime object but
increase days and hours.
Is it possible?
For example:If I have a datetime object like this
datetime.datetime(2006, 8, 3, 14, 13, 56, 609000)
I would like to make a new ,for example like this
datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)
is it possible to do so?
Yes it is, just add a `timedelta` object:
In [18]: a = datetime.datetime(2006, 8, 3, 14, 13, 56, 609000)
In [19]: a + datetime.timedelta(days=8, hours=20)
Out[19]: datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)
Ciao,
Marc 'BlackJack' Rintsch
Lad schrieb:
In a datetime object I would like to change days and hours.
Or in other words, I would like to copy this datetime object but
increase days and hours.
Is it possible?
For example:If I have a datetime object like this
datetime.datetime(2006, 8, 3, 14, 13, 56, 609000)
I would like to make a new ,for example like this
datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)
is it possible to do so?
you'd been pointed to the resources yesterday - please read manuals
carefully!
a = datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)
b = a + datetime.timedelta(days=-2, hours=-4)
Diez
On 8/3/06, Rama <ra*************@gmail.comwrote:
But wont this create a new object? Whereas if you want to modify the same
object, should we not be using replace? Or does it not matter in the global
picture?
datetime objects are immutable. You can't change the value of an
existing datetime object, only create a new one.
--
Cheers,
Simon B, si***@brunningonline.net, http://www.brunningonline.net/simon/blog/
On 8/3/06, Rama <ra*************@gmail.comwrote:
Just curious why when
I call id(a) I get the same id after I call the replace method.
In your example, you called a's replace() method, but did nothing with
the new datetime object that it returned. The original object, a,
naturally still has the same ID, but it also still has the same value.
--
Cheers,
Simon B, si***@brunningonline.net, http://www.brunningonline.net/simon/blog/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Grant Edwards |
last post by:
Is it true that a datetime object can convert itself into a
string, but not the other way around? IOW, there's no simple
way to take the output from str(d) and turn it back into d?
So, I tried...
|
by: Carl |
last post by:
Hi, to be use with SQL server database
1- From window form textbox object
From this assignement,
txtTOTAL.Text="0.00m";
How do you convert back to decimal type ?
How do you assign a...
|
by: Jimmie |
last post by:
Hiya all, very quick question, I hope .. I have an xml dump of some old data
that I need to parse and input into a new system. A couple of date fields
are in there that have the following data...
|
by: Andrew S. Giles |
last post by:
Hello,
I am importing a flat text file, and putting it into a datagrid for display
on a form.
Currently the users have their dates and times seperated. I have two
fields, therefore in the...
|
by: Alan Silver |
last post by:
Hello,
I have a custom control that displays the date and time. I currently
have properties for the day, month, year, hour and minute, which have to
be set separately. This is inefficient.
I...
|
by: Reny J Joseph Thuthikattu |
last post by:
Hi,
I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a
miniute to it.How can i do that?
by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004
12:00 AM'...
|
by: Phil B |
last post by:
I am having a problem with a datetime from a web services provider
The provider is sending the following SOAP response
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope...
|
by: Philippe Martin |
last post by:
Hi,
I need to get the date and time under Windows and Linux but need the
information visible to the user (cannot find my words) not the sytem
information (ex: a PC setup on greenwich but the...
|
by: iulian.ilea |
last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy
into it? I choose this method because I have an application that runs
on more than one server. So, if I used a datetime field...
|
by: maolimix |
last post by:
Hi to all,
I have a trouble with datetime...now I explain..
I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005.
I tried 3 methods ...in the first two I never...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |