If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Date calculator for date manipulation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-24-05, 09:11
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Date calculator for date manipulation

Anyone interested?
I've created a script for date calculations,
dateadd, datediff, Julian day number conversion and formatting


Syntax: datecalc [-j] [-f <out_date_format>] <function> <args>

Dates are dates in the proleptic Gregorion Calendar
for Julian Calendar dates use -j flag


e.g. current date: 2005-10-24
How many days to new year?
datecalc datediff 2006 1 1 `date '+%Y %m %d'`
69
end of last month
datecalc -f "dddd, d mmmm yyyy (Week ww)" dateadd `date '+%Y %m'` 1 -1
Friday, 30 September 2005 (Week 39)
The last day Great Britain used the Julian calendar was 1752-09-02
wat was the julian day number and what was the next date

datecalc -j jd 1752 9 2 # Get julian day number
2361221
echo $(datecalc -f 'ddd yyyy-mm-dd' jc 2361221) was followed\
by $(datecalc -f 'ddd yyyy-mm-dd' gc 2361222)
Wed 1752-09-02 was followed by Thu 1752-09-14
How many days to drop in 1582 when Italy changed
from the Julian calendar to the Gregorian calendar

echo $(( $(datecalc -j jd 1582 10 4) - $(datecalc jd 1582 10 4) ))
10
ordinal day number in particular year (like date +%j)
datecalc od 2004 3 1
61
what is the gregorian calendar date for ordinal date 2004-60
datecalc -f "yyyy-mm-dd" gc 2004 60
2004-02-29
On what date is easter in 2010
datecalc -f "d-mmm-yyyy" easter 2010
4-Apr-2010
ISO 8601 week number (yyyy-Www-d) for 2005-01-01
datecalc isoweek 2005 1 1
2004-W53-6
Reply With Quote
  #2 (permalink)  
Old 10-25-05, 01:59
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Script for date calculations

Sorry, I forgot to attach the script. Here it is.
Attached Files
File Type: txt datecalc.txt (10.7 KB, 313 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On