473,785 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to concatenate datetime.date object and datetime.time object

Actually I am trying to save both date and time in one cell but they
are given separately by user.
Aug 5 '08 #1
2 11123
On Tue, 05 Aug 2008 02:25:34 -0700, Will Rocisky wrote:
Actually I am trying to save both date and time in one cell but they are
given separately by user.
What's a "cell"?

I suggest building a datetime.dateti me() object:
>>date = datetime.date(2 008, 8, 5)
time = datetime.time(1 9, 54)
datetime.date time.combine(da te, time)
datetime.dateti me(2008, 8, 5, 19, 54)

I discovered this by opening an interactive session and calling
help(datetime).
--
Steven
Aug 5 '08 #2
Will Rocisky wrote:
Actually I am trying to save both date and time in one cell but they
are given separately by user.
http://docs.python.org/lib/datetime-datetime.html indicates that the
function you're looking for is datetime.dateti me.combine(d, t).

HTH!

--
I'm at CAMbridge, not SPAMbridge
Aug 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2543
by: Harald Hanche-Olsen | last post by:
I'm confused. I was going to try linkchecker, and it dies with a traceback ending in File "/usr/local/lib/python2.4/calendar.py", line 32, in _localized_month _months = AttributeError: 'module' object has no attribute 'date' Sure enough, there is no datetime.date, but there is a datetime.Date: Python 2.4 (#2, Feb 19 2005, 20:35:23)
3
35104
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
3
15827
by: Omer kamal | last post by:
Dear all, I want to save my data into MS Access database Table which consist of some fields with short date and short time formats. I try to save data in to the said table and I am getting error that my SQL statment is not correct. string strSQL = @"INSERT INTO Activities ( Task,Day,Start,Finish ) VALUES ( '"+id+"', '"+date+"', '"+start+"', '"+finish+"' )" ;
3
14775
by: Larry Bertolini | last post by:
For some reason, I recall having read that SQL Server 2005 would support a datatype that represented date, but not time. (This would be useful for storing things like birthday, where you usually don't care about the time of day). But I've got SQL Server 2005 installed, and there's no such datatype to be found. Is this something that might be released in a Service Pack, or is it just not going to happen?
4
23934
by: Grant Merwitz | last post by:
Hi, I'm trying to enter the time in the following format: HH:MM:SS AM/PM e.g. 05:33:21 PM How can i achieve this from the Date Time object? DateTime.Now.ToString("?");
1
2524
by: Mike Rooney | last post by:
Hi everyone, this is my first post to this list. I am trying to create a subclass of datetime.date and pickle it, but I get errors on loading it back. I have created a VERY simple demo of this: import datetime class MyDate(datetime.date): """ This should be pickleable.
7
3411
by: Shani Aulakh | last post by:
Hi there, I have a FolderWatcher.cs class that will monitor a given folder and delete files older than X number of days. I have the following methods. I need to add/show delete mothod using date time object. public static DateTime GetRelativeDateTime(int days, int hours, int minutes) { return DateTime.Now.AddDays(-days).AddHours(-hours).AddMinutes(-minutes); }
10
4026
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one problem. This function does not recognize time zones. How to adjust date to user's time zone? Is converting to timestamp() and then to format readable to visitors the one and only solution (e.g. strtotime() + date() OR DateTime object)? Perhaps,...
7
3601
by: w41ter | last post by:
I'm writing a very simple python program to read in an ascii csv file with multiple records formatted like this: "2010.3.13, 0.0.0, 10.1, 12.2, 9.9, 10.1, 2500" # i.e. a list of daily stock prices with date,time,open,high,low,close,volume fields I use this python code to read each line from the ascii file named f: for line in f: d,t,o,h,l,c,v = line.split(',') # where d stands for date, etc Much to my pleasant shock, the ascii...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.