Solved

convert DATE into DAY NUMBER (JULIAN/ORDINAL) in YYDDD FORMAT

Posted on 2013-05-10
4
733 Views
Last Modified: 2013-05-15
HI Experts,

I need a webpage with js in it so users can put in a normal date for it to be converted to JULIAN/ORDINAL in the format of YY/DDD

I have had a look online but cant find one in this format.

Please see attachment for example.

Any help would be appreciated,

Thanks
0
Comment
Question by:Richiep86
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39155572
please provide of what you've
and what you want
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39155987
I don't see an attachment.
0
 
LVL 7

Accepted Solution

by:
dimmergeek earned 500 total points
ID: 39162939
Without an attachment, it's difficult to know exactly what you're after, but....

<html>
<head>
<title>Date Conversion</title>
<script type="text/javascript" language="javascript">
    function GtoJ(formName) {
		var monthGreg = parseInt(formName[0].value);
		var dayGreg = parseInt(formName[1].value);
		var yearGreg = parseInt(formName[2].value);

		var dateStamp = new Date().setFullYear(yearGreg, monthGreg, dayGreg);
		var d = new Date();
		var first = new Date().setFullYear(2013,0,1);
		var theDay = Math.round(((dateStamp - first) / 1000 / 60 / 60 / 24) + .5, 0);
		var julian = (String(yearGreg).substring(4, 2) + "/" + theDay);
		formName[4].value = julian;
}
</script>
</head>
    <body>
        <form name="calForm" action="">
            <table align="center" border="5" cellpadding="5">
                <tr bgcolor="#FFFFFF">
                    <td bgcolor="#B6D4D2"><h2 align="center">Calendar Date Entry:
                        <select name="month">
                            <option value="">Select Month...</option>
                            <option value="0">January</option>
                            <option value="1">February</option>
                            <option value="2">March</option>
                            <option value="3">April</option>
                            <option value="4">May</option>
                            <option value="5">June</option>
                            <option value="6">July</option>
                            <option value="7">August</option>
                            <option value="8">September</option>
                            <option value="9">October</option>
                            <option value="10">November</option>
                            <option value="11">December</option>
                        </select>
                        &nbsp;&nbsp;
                        <input type="text" name="day" value="Day" size="3" maxlength="2" onfocus="this.value='';" />
                        &nbsp;&nbsp;
                        <input type="text" name="year" value="Year" size="5" maxlength="5" onfocus="this.value='';" /></h2><br /><br />
                        <center>
                            <input type="button" value="Click to convert Calendar Date to Julian..." onclick="GtoJ(calForm);" />
                        </center>
                        <h2 align="center">Julian Date: <input type="text" name="julianDay" /></h2>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

Open in new window

0
 

Author Closing Comment

by:Richiep86
ID: 39169108
Perfect, thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question