2017-08-18 15 views
0

Ich erhalte Julian Datum und Uhrzeit von jde Tabelle als:Julian Datum und Uhrzeit regelmäßig Datum und Uhrzeit

SLUPMJ(Date) | SLTDAY(Time) 
--------------------------- 
116173  | 94959 

muss ich sie in regelmäßigen Datums- und Zeitwerte konvertieren in meine Anwendung zu integrieren.

Während ich das Datum Teil mit benutzerdefinierten Code Konzert bin in der Lage:

DCY = Left(Date1, 3) 

If Left(DCY, 1) = "0" Then 
    DYear = "19" & Right(DCY, 2) 
Else 
    DYear = "20" & Right(DCY, 2) 
End If 

Dinterval = CInt(Right(Date1, 3)) 

TDate = DateAdd("d", Dinterval - 1, "01/01/" & DYear) 
J2D2 = Day(TDate) & "/" & Month(TDate) & "/" & Year(TDate) 

Wie konvertiere ich die Zeit an vb.net?

+0

Check [hier] (https://stackoverflow.com/questions/6883324/date-time -format-convert-in-vb-net? rq = 1) könnte eine Hilfe sein – JSON

+0

Sie sollten uns zeigen, was die Ausgabe für die gegebene Eingabe sein soll. Es wäre auch toll, wenn Sie eine Referenz angeben könnten, die das Eingabeformat beschreibt. – Enigmativity

+0

Sollte das Ergebnis Mittwoch sein, wird B.C. 4395 Jan 25 \t 10: 47: 24,6? http://aa.usno.navy.mil/jdconverter?ID=AA&jd=116173.94959 – Slai

Antwort

1

Hier ist ein Code zum Konvertieren des Zeitabschnitts eines Julianischen Datums. Es ist wahrscheinlich ein einfacher Weg, aber Coding sollte hart sein! ™ :)

''' <summary> 
''' Converts the time portion of a Julian datetime 
''' </summary> 
''' <param name="dJDateTime">The Julian datetime. For example: 2457984.021181</param> 
''' <returns>The time, formatted as follows: d:hh:mm:ss.mmm</returns> 
Function ConvertJulianTime(ByVal dJDateTime As Decimal) As String 
    ' Julian time is calculated as a fraction of a 24-hour period, starting from noon. 
    ' So a value >= .5 is a morning hour on the next day 

    ' Get the fractional part of the Julian datetime, which is the time 
    Dim dJTime As Decimal = GetFractionalPart(dJDateTime) 
    ' Get time in seconds 
    Dim dJTimeInSec As Decimal = 86400 * dJTime + 43200 ' 43200 is half a day in seconds 
    ' Calculate the hours 
    Dim dJTimeInHours As Decimal = dJTimeInSec/3600 
    ' If the value is >= 24, it's a morning hour so increment the day value 
    Dim intDay As Integer = 0 
    If dJTimeInHours >= 24 Then 
     dJTimeInHours = dJTimeInHours - 24 
     intDay = 1 
    End If 
    ' Calculate the minutes 
    Dim dJTimeInHoursMin As Decimal = GetFractionalPart(dJTimeInHours) * 60 
    ' Calculate the seconds 
    Dim dJTimeInHoursSec As Decimal = GetFractionalPart(dJTimeInHoursMin) * 60 
    ' Calculate the milliseconds 
    Dim dJTimeInHoursMSec As Decimal = GetFractionalPart(dJTimeInHoursSec) * 1000 
    ' Build the result and display it 
    Dim tsSpan As New TimeSpan(intDay, CInt(Math.Truncate(dJTimeInHours)), 
           CInt(Math.Truncate(dJTimeInHoursMin)), 
           CInt(Math.Truncate(dJTimeInHoursSec)), 
           CInt(Math.Truncate(dJTimeInHoursMSec))) 
    Return tsSpan.ToString("d\:hh\:mm\:ss\.fff") 
End Function 
''' <summary> 
''' Given a decimal, gets the fractional part only. For example, for 1234.5678, returns 0.5678 
''' </summary> 
''' <param name="dNumber">The decimal.</param> 
''' <returns>The fractional part of the decimal.</returns> 
Function GetFractionalPart(ByVal dNumber As Decimal) As Decimal 
    Dim dInt As Decimal = Math.Truncate(dNumber) 
    Return (dNumber - dInt) 
End Function 

End Class

+0

Warum wurde mein Code nicht akzeptiert? – Squidx3