Solved

Conversion of Jualian Date entry to standard Date

Posted on 2008-06-13
11
116 Views
Last Modified: 2010-04-09
Hopefully a simple answer for this one but I need it quickly so here goes.

I need a form that when a person plugs in a 3-digit Julian date representing the day of the year then hits submit and the standard date appears.  Such as someone types in 165 then hits submit (or if no button is required and something automatically does it would be cool) then a field below it states Jun 13, 2008

Any ideas?
0
Comment
Question by:austintre
  • 6
  • 5
11 Comments
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
So the Julian date corelates allways the the current Year, right?
0
 

Author Comment

by:austintre
Comment Utility
Yes exactly
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
Comment Utility
Check this:
<html>

<head>

<title>Zvonko &#42;</title>

<script>

function getDate(theField){

  var theForm = theField.form;

  var jDay = theField.value.replace(/\D/g,'');

  if(jDay!=theField.value) theField.value = jDay;

  theForm.date.value = "";

  if(jDay){

    var theDate = new Date();

    var YY = theDate.getFullYear();

    var theDate = new Date(YY,0,jDay);

    var MM = theDate.getMonth()+1;

    var DD = theDate.getDate();

    theForm.date.value = d2(DD)+"."+d2(MM)+"."+YY;

  }

}

function d2(theNum){

  if(theNum<10) return "0"+theNum;

  return theNum;

}

</script>

</head>

<body>

<form>

<input type="text" name="julian" size="3" maxlength="3" onKeyUp="getDate(this)" >

<input type="text" name="date" size="10" onFosus="this.blur()" >

</form>

</body>

</html>

Open in new window

0
 

Author Comment

by:austintre
Comment Utility
That works - but can I format it so that it shows Jun 13, 2008?  If not this is good enough!

Cheers
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Open a new question for that :-)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:austintre
Comment Utility
That was part of the question to begin with.  

That is like me going to my doctor and asking for a diagnosis and he hands it to me in French and then tells me to come back again tomorrow so he can bill me again to get it in English.
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
So in English: Is it really for you a problem to convert the MM number to one of twelve Month names?
0
 

Author Comment

by:austintre
Comment Utility
Yes it is considering I have no clue how to use JavaScript.  I don't do this for a living.  Just trying to help someone out.  But don't worry about it.  Sorry to have wasted your "genius" time.  

Thank you for the solution you gave it got me far enough.
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
For a ThankYou I do everything ;-)
<html>

<head>

<title>Zvonko &#42;</title>

<script>

function getDate(theField){

  var theForm = theField.form;

  var jDay = theField.value.replace(/\D/g,'');

  if(jDay!=theField.value) theField.value = jDay;

  theForm.date.value = "";

  if(jDay){

    var theDate = new Date();

    var YY = theDate.getFullYear();

    var theDate = new Date(YY,0,jDay);

    var MM = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(',')[theDate.getMonth()];

    var DD = theDate.getDate();

    theForm.date.value = MM+" "+d2(DD)+", "+YY;

  }

}

function d2(theNum){

  if(theNum<10) return "0"+theNum;

  return theNum;

}

</script>

</head>

<body>

<form>

<input type="text" name="julian" size="3" maxlength="3" onKeyUp="getDate(this)" >

<input type="text" name="date" size="10" onFocus="this.blur()" >

</form>

</body>

</html>

Open in new window

0
 

Author Comment

by:austintre
Comment Utility
Thank you
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
:-)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

10 Experts available now in Live!

Get 1:1 Help Now