LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2013, 01:32 PM   #1
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 166
Blog Entries: 1

Rep: Reputation: 4
python: comparing dates


Hi. In a django project we are pulling the date from a user input field using the strptime function, which is the only way I knew how to do that. Like so:

Code:
try:
    start_date = strptime(request.GET["date_range_start"], '%m/%d/%Y')
except ValueError:
    ....

try:
    end_date = strptime(request.GET["date_range_end"], '%m/%d/%Y')
except ValueError:
    ...
But the values returned by this func apparently cannot be compared using the <> operators. What is the equivalent way of doing this using the date class? Or how do I translate the struct_time values into a date object?
 
Old 03-11-2013, 04:25 PM   #2
lambo69
Member
 
Registered: Sep 2012
Distribution: Slackware, Manjaro, Slackarm, Raspbian, Debian
Posts: 68

Rep: Reputation: Disabled
Try to use unix timestamps to do such comparisons and computing on dates. Have a look at time.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python matplotlib postgresql xaxis as dates fur Programming 4 01-16-2013 04:39 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 04:50 AM
Comparing dates with ruby lmcilwain Programming 5 03-10-2007 02:29 PM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration