Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Convert Date to Julian Date

Thread Tools Display Modes
Old 05-13-2004, 02:59 AM
bbrendan bbrendan is offline
Join Date: Sep 2003
Posts: 36
Default Convert Date to Julian Date

Hi im hoping someone can help me here please.

I have a datetime picker which returns a selected date like:

I need to convert this to a julian number.

In excel its easy you just change the format to number an boom you get

So how would I change it when I select a date.

Its just that all our dates are stored in Julian dates

Reply With Quote
Old 05-13-2004, 03:06 AM
BenTiC BenTiC is offline
Join Date: Jun 2003
Posts: 32

you might try the function Dateserial( Year(YourDatePicker), Month(YourDatePicker), Day(YourDatePicker))

this returns a double... like 38014,73333...
Reply With Quote
Old 05-13-2004, 07:07 AM
LaVolpe's Avatar
LaVolpe LaVolpe is offline
Ultimate Contributor

* Expert *
Join Date: Apr 2004
Location: Illinois
Posts: 2,499

BenTiC is correct... CDbl(CDate("01/12/2004")) would return that similar to Excel. The date format you are referencing is not Julian. Julian dates are a number between 1 & 366 and usually preceded by a 2-digit year: Your example date would be 04012 in Julian format.
Insomnia is a simple byproduct of "it can't be done" {Window Shaper}
Reply With Quote
Old 05-13-2004, 10:26 AM
loquin's Avatar
loquin loquin is offline
Google Hound

Retired Moderator
* Guru *
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,398

Lavolpe: I would probably say Julian dates are sometimes preceeded by a year number.

bbrendan: To get a julian day,
strJulian = Format(dtYourDate, "y")
To get a day number, just cast it as double...
Dim dblDayNum as Double dblDayNum = dtYourDate

the date datatype is simply a double, formatted/presented as a date. The number represents the number of days since Midnight, Dec 30, 1899. The integer portion of the number represents the number of days; the fractional part (portion to the right of the decimal point) represents the fraction of the day that has passed. For instance, 1.25 formatted as a date/time would return 12/31/1899 06:00:00, as THAT is 1 - 1/4 days after the base date.
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown

Last edited by loquin; 05-13-2004 at 10:36 AM.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Canot close forms robojam Excel 7 03-02-2004 01:14 PM
Program Expiration Script question ngl1145 File I/O and Registry 2 02-26-2004 03:41 PM
DTS: Cast from julian date to DateTime Alien777 Database and Reporting 1 02-12-2004 06:31 AM
comparing dates with visual foxpro and ado azwaan General 8 01-08-2002 06:50 AM
Convert Unix to Oracle Date carlco Database and Reporting 1 07-24-2001 05:13 PM


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..