VB Date Conversion

How do you convert julian dates to mm/dd/yyyy?
DGCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
É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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.