Solved

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

Posted on 2013-05-10
4
711 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now