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 02-11-2008, 02:52 PM   #1
johnfman
LQ Newbie
 
Registered: Sep 2007
Posts: 13

Rep: Reputation: 0
Question date increment not working on certain dates


OK What's up with this?? I'm creating daily partitions for an oracle table, and using the '+1 days' increment feature of 'date' but one day in particular WON'T increment!!! Here's what the script does with Nov 3, 2007: (NOTE: the +1 days function only works with the date in yy-mm-dd format)

Code:
$ D=071103
$  echo $D
071103
$ D_DATE=`date +"%Y-%m-%d" -d "$D"`
$   echo $D_DATE
2007-11-03
$  date -d "$D_DATE"
Sat Nov  3 00:00:00 EDT 2007
$ NEXT_DAY=`date +"%y%m%d" -d "$D_DATE +1 days"`
$  echo $NEXT_DAY
071104
OK fine, Nov 3rd became Nov 4th, just like we wanted. Now watch on Nov 4 (and note that the date is incremented only 23 hours ahead!)

Code:
$ D=071104
$  echo $D
071104
$ D_DATE=`date +"%Y-%m-%d" -d "$D"`
$  echo $D_DATE
2007-11-04
$ date -d "$D_DATE"
Sun Nov  4 00:00:00 EDT 2007
$ date -d "$D_DATE +1 days"
Sun Nov  4 23:00:00 EST 2007
$ NEXT_DAY=`date +"%y%m%d" -d "$D_DATE +1 days"`
$ echo $NEXT_DAY
071104
Nov 4th plus one day is Nov 4th!!! Whats up with that????

John F
 
Old 02-11-2008, 04:14 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
Time zones? your using EST not GMT so daylight saving is being taken into account.
 
Old 02-15-2008, 11:14 AM   #3
johnfman
LQ Newbie
 
Registered: Sep 2007
Posts: 13

Original Poster
Rep: Reputation: 0
OK, makes sense, but why on this particular day and not on others?
 
Old 02-15-2008, 11:38 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Daylight saving time change fell on 4 Nov. Try 11 Mar 2007 and see if it works in reverse.
 
  


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
oracle + working with date/week champ Programming 8 11-28-2011 05:45 PM
date function working differently between machines johnfman Linux - Software 3 12-21-2007 11:24 AM
how working opensuse for up to date releases? dissident_goodchild Linux - Newbie 6 11-20-2007 05:26 PM
increment in hex snutz411 Linux - Newbie 2 11-01-2005 05:54 PM
Trouble working with file dates cboxall Linux - Newbie 2 07-21-2005 11:11 AM

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

All times are GMT -5. The time now is 03:16 PM.

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