[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

VB Date Conversion

How do you convert julian dates to mm/dd/yyyy?
0
DGC
Asked:
DGC
1 Solution
 
BSmileyCommented:
Dates are stored internally as a real number.  So you should be able to convert your julian date to a real date by a simple subtraction. It depends upon the base for your julian date (are you using a real Julian, or a 1900-based julian?)

The internal number stores the number of days since December 30, 1899.  Therefore, if your julian date is the number of days since 1/1/1900, then you would already be close: just add 2, then use the FormatDateTime() function to convert it to a string, or CDate() function to convert it to a date.

I've never tried this, but it should work.

Hope this helps.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I suppose that your Julian date is something like yyddd.

If so, there is something I already use:
Private Sub Command1_Click()
Dim dtmNewDate As Date
Dim strJulianDate As String

    strJulianDate = "99123"
   
    dtmNewDate = DateSerial(Left$(strJulianDate, 2), 1, 1)
    dtmNewDate = DateAdd("d", Val(Right$(strJulianDate, 3)) - 1, dtmNewDate)
    MsgBox Format(dtmNewDate, "mm/dd/yyyy")
End Sub
0
 
SharmiCommented:
You can use this function to convert julian date


Function ConvertJulian (JulianDate as Long)
ConvertJulian = DateSerial(1900 + _
Int(JulianDate / 1000), _
1, JulianDate Mod 1000)  
End Function


Thanks
Sharmi
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
DGCAuthor Commented:
Thanks for the help.
0
 
DGCAuthor Commented:
emoreau,
Your comment was great!  I used it and was successful.  I really appreciate the time you took to think about what I had asked.
Thanks!!!
0
 
BSmileyCommented:
DGC:

It's good that emoreau's answer worked for you, but you assigned the points to me!

In the future, you could reject my answer and then select emoreau's for the points.  (I'm new and just figuring this sort of thing out myself.)

I've posted a question to tech support so they'll adjust the points to give them to emoreau instead.

=Bob
0
 
ianBCommented:
Hi,

I have been directed to this question by BSmiley , I have posted a question for emoreau  to claim the points for this question, (Q.10245416)

Ian
Community Support @ Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now