0

Is it possible to display the current 4 digit Julian date (YDDD) at the top of a column above a web part?

I've been trying to google and insert a javascript code in the modify HTML portion when editing the page, but I am not very good at coding.

Any help would be greatly appreciated.

Thank you in advance!

0

Little code fragment to assist with conversion to and from Julian date format.

public static long ToJulian(DateTime dateTime)
{
    int day = dateTime.Day;
    int month = dateTime.Month;
    int year = dateTime.Year;

    if (month < 3)
    {
        month = month + 12;
        year = year - 1;
    }

    return day + (153 * month - 457) / 5 + 365 * year + (year / 4) - (year / 100) + (year / 400) + 1721119;
} 

public static string FromJulian(long julianDate, string format) 
{ 
    long L = julianDate + 68569; 
    long N = (long) ((4*L)/146097); 
    L = L - ((long)((146097 * N + 3)/4) ); 
    long I = (long) ((4000 *(L + 1)/1461001)) ; 
    L = L - (long)((1461*I)/4) + 31;  
    long J = (long)((80*L)/2447);  
    int Day = (int)(L - (long)((2447*J)/80)); 
    L=(long)(J/11) ; 
    int Month = (int)(J + 2 - 12*L); 
    int Year = (int)(100*(N-49) + I + L) ; 

    // example format "dd/MM/yyyy"
    return new DateTime(Year,Month,Day).ToString(format); 
}
  • Is above solution works for you? – Hardik May 9 '17 at 14:08
  • I couldn't get this script to work. I'm far from an expert, but it doesn't seem to follow the same format as the html scripts I see when I edit the page through share point editor. – J-L May 11 '17 at 16:31
  • Still no solution on this questions. The answer posted was a copy/paste from yahoo answers. It did not work. – J-L May 23 '17 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.