Get current day on Julian date format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get current day on Julian date format
# 1  
Old 01-18-2011
Get current day on Julian date format

Hi guys,

I know if I try to get a julian date using a specific date I can but I try to get the current date I got an error as you can see below:

This one works fine:
Code:
date -d "2010/10/30" +%j

But I can't get the current date as below:
Code:
`date -d "+%Y/%m/%d`" +%j

Does somebody can help me please??

Edu
# 2  
Old 01-18-2011
Tools may be simpler

why not
Code:
date +%j

This User Gave Thanks to joeyg For This Post:
# 3  
Old 01-18-2011
Code:
`date -d "+%Y/%m/%d`" +%j

There are syntax errors in this

try
Code:
a=`date -d "+%Y/%m/%d" +%j`
# or
a=$(date -d "+%Y/%m/%d" +%j )
echo $a

This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 01-18-2011
It works fine, thx..

Now I have to pass a dynamic day as parameter for example below:

`date +%y``date -d +%m/$my_day_variable/%Y` +%j`

How it can works having a dynamic day variable, also my result shoud be like this:

11018 or yyddd

I really appreciate your help my friend.

Thanks...
# 5  
Old 01-18-2011
How about:

Code:
$ my_day_var=21
$ date -d $(date +%b-$my_day_var-%Y) +%y%j
11021


Last edited by Chubler_XL; 01-18-2011 at 11:14 PM..
# 6  
Old 01-20-2011
Julian date now on UNIX AIX

My friend, I was testing the command to get the julian date on Linux, when I tested the commands on UNIX AIX as below I got the messages error:

Code:
plan_day_ori="${day}/${mon}/${year}"
date -d "$plan_day_ori" +%y%j

date: illegal option -- d
Usage: date [-u] [+Field Descriptors]

Does anybody knows if there is any difference with that command on AIX and How I can have the same result on the AIX?

Thanks
# 7  
Old 01-20-2011
Yes -d and --date parameters are not supported in the AIX version of date.

You could try some of the solutions presented in the FAQ: https://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to get first & last day of a month from current date?

Hi, I need the first & last day of a month from any given date. For better understanding, if i need to back-fill data for date 07/20/2019 i.e July 20 2019, i need the first & last day has 07/01/2019 - 07/31/2019. FYI: I'm using GIT BASH terminal. sample code: export DT=$(date --date='6 days... (2 Replies)
Discussion started by: Rocky975583
2 Replies

2. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

3. Shell Programming and Scripting

Julian day to dates in YEAR-MONTH-DAY

hello, I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc. I need to do it for several years and leap years as well. What is the best way to do it ? Thank you. (1 Reply)
Discussion started by: Ggg
1 Replies

4. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. Shell Programming and Scripting

Converting filenames from julian day to yyyy-mm-dd and retrieving weekly mean values

Hi, I need help to convert the filenames of my 9-year daily files (1999-2007) from a julian day to yyyy-mm-dd format. my original files are patterned likes the ones below. 1999001.txt 1999002.txt 1999003.txt 1999004.txt ... 1999365.txt desired output: 19990101.txt 19990102.txt... (3 Replies)
Discussion started by: ida1215
3 Replies

6. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

7. Shell Programming and Scripting

Julian date to Calendar date conversion

Hi all, I require to convert julian date to normal calander date in unix for eg julian date=122 now i want corresponding calander date ---------------------------------------- gr8 if give very small command/script and please explain the steps as well(imp) Thanks ... (3 Replies)
Discussion started by: RahulJoshi
3 Replies

8. Shell Programming and Scripting

Date after 5 days from current date in YYYYMMDD format

Hello Experts, How do i get date after 5 days from current date in YYYYMMDD format? How do you compare date in YYYYMMDD format? Thanks (8 Replies)
Discussion started by: needyourhelp10
8 Replies

9. Shell Programming and Scripting

Get yesterday's date in year-month-day format?

Dear All, Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report. to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies

10. UNIX for Dummies Questions & Answers

I want to get day from the current system date

Hi, I want to check what day is today (like mon,Tue,wed) When i checked the syntax, i dont see there is a format specifier for getting the day. Let me know how to get the same. I am very new to unix and so I am asking some basic questions. cheers, gops (2 Replies)
Discussion started by: gopskrish
2 Replies
Login or Register to Ask a Question