Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-29-2007, 08:58 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 14

Rep: Reputation: 0
how to compare date string??

i have query two date from database to two variables a and b;
a:2007-12-01 01:00:00
b:2007-11-31 22:00:00

i want to compare two date that which one is the latest day?
so how can i do with using if command or other command??
Old 11-29-2007, 09:40 PM   #2
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,829

Rep: Reputation: 108Reputation: 108

If you are using C, strptime() may be what you want.

If 3 min past 7 o'clock January 1st 2007 is 2007-01-01 07:03:00 (note leading zero), just comparing them in character string may be good enough.

Hope this helps.

Happy Penguins!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to compare the output of a command with a string? daYz Programming 2 12-31-2006 10:36 AM
Compare first characters of a string in UNIX shell loopoo Linux - Newbie 8 12-11-2006 12:35 PM
compare string in SQL hus Programming 9 04-27-2005 11:17 AM
compare string in C++ danxl Programming 3 11-02-2003 03:14 PM
php date compare omarswan Programming 2 10-02-2002 05:41 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:28 AM.

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