473,241 Members | 1,527 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,241 software developers and data experts.

Get the current date, python 2.2

Using python 2.2 what is the simplest way to get the current date value?
I have looked in so many places. The question is often asked and the
usual response indicates how to get the current date and time like

now = time.localtime()

I want just the date, like 2007-06-15. The value will go into a
postgresql Date type column.

Also, if postgres field of this type is set to time.localtime(), is the
time portion of the date discarded, or stored 'invisibly', of will there
be an error of some type? Just thought someone here might know.
Jun 15 '07 #1
3 6228
On Fri, 15 Jun 2007 14:30:36 -0700, nano wrote:
Using python 2.2 what is the simplest way to get the current date value?
I have looked in so many places. The question is often asked and the
usual response indicates how to get the current date and time like

now = time.localtime()

I want just the date, like 2007-06-15. The value will go into a
postgresql Date type column.
>>import datetime
d = datetime.date.today()
d.isoformat()
'2007-06-15'
>>>
Rob.
Jun 15 '07 #2
In article <KJ*********************@pipex.net>, rt*@freenet.co.uk
says...
On Fri, 15 Jun 2007 14:30:36 -0700, nano wrote:
Using python 2.2 what is the simplest way to get the current date value?
I have looked in so many places. The question is often asked and the
usual response indicates how to get the current date and time like

now = time.localtime()

I want just the date, like 2007-06-15. The value will go into a
postgresql Date type column.
>>import datetime
>>d = datetime.date.today()
>>d.isoformat()
'2007-06-15'
>>>

Rob.
Thanks, I'd read that today() was only good for 2.3?
Jun 15 '07 #3
On Fri, 15 Jun 2007 14:46:20 -0700, nano wrote:
In article <KJ*********************@pipex.net>, rt*@freenet.co.uk
says...
>On Fri, 15 Jun 2007 14:30:36 -0700, nano wrote:
Using python 2.2 what is the simplest way to get the current date
value? I have looked in so many places. The question is often asked
and the usual response indicates how to get the current date and time
like

now = time.localtime()

I want just the date, like 2007-06-15. The value will go into a
postgresql Date type column.
> >>import datetime
d = datetime.date.today()
d.isoformat()
'2007-06-15'
> >>>
Rob.
Thanks, I'd read that today() was only good for 2.3?
Right I missed that, though its actually the datetime module that
is new in 2.3.

This should do though:
>>import time
time.strftime( "%Y-%m-%d" )
'2007-06-15'
>>>
--
Rob.
Jun 15 '07 #4

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

Similar topics

3
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:...
14
by: deko | last post by:
This runs, but does not narrow to current week. suggestions appreciated! SELECT lngEid, dtmApptDate, Subject, Appt_ID FROM qry002 WHERE (dtmApptDate BETWEEN DateAdd("d",-weekday()+2,) And...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
6
by: vijayk | last post by:
Hi all, I have a field which has data as YYYYMMDD, and I have to find the age of the person by substracting it from current date. can you please please advice... thanks
2
by: markryde | last post by:
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime
0
by: Shawger Lager | last post by:
Hi, I am new to DB2 (and SQL) and I am having some problems with the current date. I am trying to make sure the date in the table review is not past the current day using a constriant. I have tried...
0
by: remya1000 | last post by:
I need to display current month,last 3months,6months and 1year records seperatly. and first i'm tring to display current month's records. and the error i received is this. Microsoft VBScript...
5
by: bruce24444 | last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.