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


Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2004, 02:59 AM
bbrendan bbrendan is offline
Freshman
 
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:

01/12/2004
I need to convert this to a julian number.

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

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

Its just that all our dates are stored in Julian dates

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

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

this returns a double... like 38014,73333...
Reply With Quote
  #3  
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
Default

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
  #4  
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,402
Default

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

bbrendan: To get a julian day,
Code:
strJulian = Format(dtYourDate, "y")
To get a day number, just cast it as double...
Code:
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.
__________________
Lou
"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
Reply


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 12:14 PM
Program Expiration Script question ngl1145 File I/O and Registry 2 02-26-2004 02:41 PM
DTS: Cast from julian date to DateTime Alien777 Database and Reporting 1 02-12-2004 05:31 AM
comparing dates with visual foxpro and ado azwaan General 8 01-08-2002 05:50 AM
Convert Unix to Oracle Date carlco Database and Reporting 1 07-24-2001 05:13 PM

Advertisement:





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.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
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..
subscribe
 
 
-->