473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to format datetime values

A.M
Hi,

I have a datetime value and want to format it to "June 1, 2006" shape. How
can I do that?

Thank you,

Alan


Jun 1 '06 #1
5 2608
Are you trying to get banned, or what?

It's the equivalent of me asking you:

Hey, does Ruby have anything like dictionaries and will you teach me
about strings? Oh, and what's an object?

Go read the bleeping tutorial.

rd

Jun 1 '06 #2

Alan> I have a datetime value and want to format it to "June 1, 2006"
Alan> shape. How can I do that?

Again, Python's introspection capabilities to the rescue:

% pydoct datetime
Help on module datetime:

NAME
datetime - Fast implementation of the datetime type.
...
class datetime(date)
| datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
...
| strftime(...)
| format -> strftime() style string.

Skip
Jun 1 '06 #3
On 1-Jun-06, at 2:55 PM, A.M wrote:
Hi,

I have a datetime value and want to format it to "June 1, 2006"
shape. How
can I do that?

Thank you,

Alan


Why don't you just post the specs to your program and maybe someone
will write it *FOR* you in less than a day?

This is quicker than waiting for replies:

Python Tutorial
http://docs.python.org/tut/tut.html

Module Index
http://docs.python.org/modindex.html

Cheers,

--
Paul Osman
http://www.eval.ca
Jun 1 '06 #4
A.M

"BartlebyScrivener" <rp*******@gmail.com> wrote in message
news:11*********************@j55g2000cwa.googlegro ups.com...
Are you trying to get banned, or what?

It's the equivalent of me asking you:

Hey, does Ruby have anything like dictionaries and will you teach me
about strings? Oh, and what's an object?

Go read the bleeping tutorial.

rd


Well, I did investigate all tutorial and google and I wasn't able to find
any built-in way for datetime formatting in Python. In fact I cannot find
any way to format a long integer into 99,999,9999 format. I know how to
format strings with C printf like formatter, but I am sure what I am trying
to do can't be done with C printf formatting.

I also found that mx.DateTime perfectly does date formatting and much more,
but I don't want to add another step to the deployment process.
It's the equivalent of me asking you:
and will you teach me about strings? Oh, and what's an object?


The answer to this post could be just a function name. I don't think I asked
about broad concepts such as the object or strings. What I am asking here is
just a clue.
Jun 1 '06 #5
A.M a écrit :
"BartlebyScrivener" <rp*******@gmail.com> wrote in message
news:11*********************@j55g2000cwa.googlegro ups.com...
Are you trying to get banned, or what?

It's the equivalent of me asking you:

Hey, does Ruby have anything like dictionaries and will you teach me
about strings? Oh, and what's an object?

Go read the bleeping tutorial.

rd

Well, I did investigate all tutorial and google and I wasn't able to find
any built-in way for datetime formatting in Python.


Really ?

For time formating... have you really really looked at module... 'time'?
In fact I cannot find
any way to format a long integer into 99,999,9999 format. I know how
to format strings with C printf like formatter, but I am sure what I
am trying to do can't be done with C printf formatting.


For long integer formating like your example, its not direct - maybe
look at locale formating of numbers (module... 'locale').
And I recently annouce the PQRC (on clp.announce), which can gives you
some directions:
http://www.limsi.fr/Individu/pointal/python/pqrc/
A+

Laurent.
Jun 2 '06 #6

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

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
2
by: Tatiana Zadiraka | last post by:
I use DB2 8.1 with FixPack 5. In command line for sql I get all DATE columns only in MM-DD-YYYY format. Of course, DATE('20-12-2003') gives me an error SQL0181N The string representation of a...
1
by: Tatiana Zadiraka | last post by:
Here is what I get from CLP commands db2 => VALUES date('20-12-2003') SQL0181N The string representation of a datetime value is out of range. SQLSTATE=22007 db2 => VALUES date('20.12.2003')...
8
by: Assimalyst | last post by:
Hi i have a value entered into an asp text box, procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query...
1
by: Esref Durna | last post by:
my sql server have this datetime format ( yyyy-mm-dd ) how could i change it to dd.mm.yyyy format or what should i do? thanks
13
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way...
6
by: coriolis_wong | last post by:
Hi, I need to transfer csv format file to DBase III format file. How do i do it in Python language? Any help is appreciated. Thanks.
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
2
by: shannonwhitty | last post by:
I am able to extract dates in the correct format i.e. SELECT CONVERT(VARCHAR(8), GETDATE(), 3) =dd/mm/yy My issue is that my users are selecting a date in this format and I need to select...
4
by: =?Utf-8?B?ZGNoMw==?= | last post by:
Is there a way to conditionally format a dateTime field to produce on result if the value is 10/31/2008 12:00 AM (user didn't enter a time) and another result if the value is 10/31/2008 5:30 PM...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
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...
0
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...
0
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...

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.