Sponsored Content
Full Discussion: Get day of year
Top Forums Shell Programming and Scripting Get day of year Post 302406311 by durden_tyler on Monday 22nd of March 2010 01:59:41 PM
Old 03-22-2010
Quote:
Originally Posted by pinguc
...I wold like to know the day of year from a date in input.
...But from a date in input? Smilie
...
Alternatively, if you have Perl in your system, then you can use the Date::Calc module -

Code:
$
$
$ # Date = 22-March-2010 in "YYYYMMDD" format
$ echo "20100322" | perl -M"Date::Calc qw(Gmtime Date_to_Time)" -lne '@x=unpack("A4A2A2A2A2A2"); print ((Gmtime(Date_to_Time(@x)))[6])'
81
$
$ # Date = 31-Dec-2009 9:10:11 AM in "YYYYMMDDHH24MISS" format; MM=month, HH24=24-hour, MI=minute
$ echo "20091231091011" | perl -M"Date::Calc qw(Gmtime Date_to_Time)" -lne '@x=unpack("A4A2A2A2A2A2"); print ((Gmtime(Date_to_Time(@x)))[6])'
365
$
$

tyler_durden
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Day of month and year to mmddyyyy

I have a date that looks like this: 2008/100:18:40:47.040 I need it to look like this: 2008 04 09 18 40 47 040 I have looked at datecalc and it doesn't seem like it takes the day of year for this year (or whatever year is input) and converts it into month and day. It also has to account... (2 Replies)
Discussion started by: ajgwin
2 Replies

2. Shell Programming and Scripting

Help to generate date from day of the year

Hi I want to convert the day of the year(yyyyddd) to date in mmddyy format Example: input is 2005029 --------> 29th day of 2005 I have to get the output as 01292005 ---> jan 29th 2005 I've to do this in K-Shell There were threads that dealt with coverting date to day of the year but I... (3 Replies)
Discussion started by: sudhamayeev
3 Replies

3. Shell Programming and Scripting

Awk convert from day of year to date

Hello everyone, I have a file which has day of year in one of the columns (JD=substr($0,72,3)). The bellow scripts shows me the minimum and maximum values of the JD and I would like to convert the JD to date. #!/bin/gawk -f { check=substr($0,1,1) if (check == "S") { ... (6 Replies)
Discussion started by: alex2005
6 Replies

4. Shell Programming and Scripting

Day of year to dd.mm.yyyy format

Hi, How can I convert day of year value in format(yy,doy) to normal formatted (dd.mm.yyyy) string also all of them with awk or awk system function? in_file.txt --------- 12,043 12,044 12,045 12,046 out_file.txt ---------- 12.02.2012 13.02.2012 14.02.2012 15.02.2012 imagine... (5 Replies)
Discussion started by: kocaturk
5 Replies

5. UNIX for Dummies Questions & Answers

Sort file by day of year

Hello, It's a shame to not be able to do what I need, but I am sure you will : Here is what I have in my log file : New File: 95106 Jun 6 48 TAG__KSO__2012092_0.TAB New File: 95106 Mar 26 48 TAG__KSM__2012020_0.TAB New File: 95106 Mar 26 48 TAG__KSO__2012020_0.TAB New File: 95106 May... (3 Replies)
Discussion started by: Aswex
3 Replies

6. 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
All times are GMT -4. The time now is 07:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy