473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Date conversion script

I need some help with a script I am writing. Maybe someone has some
experience with this. I need a part of the script to take a standard input,
a 3-digit ordinal date (e.g. 060), and convert it to the cardinal date,
assuming the current year (e.g. 20040229). I also need to be able to
convert parts of that string, the month, to the abbreviation (e.g. 02 to
FEB), and put the parts of that string in different places (e.g. *29*0000 -
*29*2359 *FEB* *2004*). This is for creating daily log reports.

Thanks in advance,
Jon
-Two wrongs don't make a right, but three lefts do.
Jul 19 '05 #1
1 6130
Jon Carpenter wrote:
I need some help with a script I am writing. Maybe someone has some
experience with this. I need a part of the script to take a standard input,
a 3-digit ordinal date (e.g. 060), and convert it to the cardinal date,
assuming the current year (e.g. 20040229). I also need to be able to
convert parts of that string, the month, to the abbreviation (e.g. 02 to
FEB), and put the parts of that string in different places (e.g. *29*0000 -
*29*2359 *FEB* *2004*). This is for creating daily log reports.

#!/usr/bin/perl

use warnings;
use strict;
use Date::Calc qw/Add_Delta_Days/;

my $current_year = (localtime)[5]+1900;

my $ordinal = 60;
my ($year, $month, $mday) = Add_Delta_Days($current_year, 1, 1, $ordinal-1);

my $month_t = (qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/)[$month-1];

print "$mday $month_t $year\n";
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
9
by: David Rysdam | last post by:
I have a large amount of data that I copy in and out of Sybase very often. Now I also want to copy this data in and out of postgres. I have an existing script that creates the entire database(s)...
2
by: markryde | last post by:
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
4
by: Jim Florence | last post by:
Hello, I've just started in ASP and I'm having a few teething problems. Initially I tried to write out dates from the database using <asp:Label runat="server" ID="Label6" Text='<%#...
0
by: Rajkishore Kumar | last post by:
We have a piece of code written in Java Script in an ASP.Net appln in Visual Studio 2003 and it works fine. What it does is , when you press a date icon , it would open up a calendar(prepared by...
6
by: vdicarlo | last post by:
I am a programming amateur and a Python newbie who needs to convert about 100,000,000 strings of the form "1999-12-30" into ordinal dates for sorting, comparison, and calculations. Though my script...
3
by: mantrid | last post by:
Hello I have date and time in my mysql table in the form 2007-05-03 00:00:00 which I have dispayed on my webpage using echo $selldatetime I want to know how I can display it in the form...
2
by: anderst | last post by:
Hi! I need help with date conversion, I need a perl-script that transform Wed Mar 28 00:00:00 GMT+02:00 2007 to 2007-03-28 I have tried to use perl modules Date::Manip and Date::Calc, but no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.