Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert to julian date function

Status
Not open for further replies.

jcroft

Programmer
Aug 23, 2001
52
US
Is there such a creature that will convert system date to julian date, convert variable to julian date?? Do the date functions interpret dates correctly no matter what system settings are on the serving or client machines?
 
here are two VBA functions I have
Maybe you coudl make them work in VBScript
----------------------------------------------
the first convert normal date to Julian 12/03/1999 to 990312

Function NormalToJulian(Date1)
Dim NormalDate As Date 'The serial date.
Dim DateYear As String 'The year of the serial date.
Dim JulianDay As String
Dim JulianDate As String 'The converted Julian date value

DateYear = Format(Date1, "yyyy") 'Find the year number for NormalDate
JulianDay = Format(Str(Date1 - DateValue("1/1/" & Str(DateYear)) + 1), "000")

'Combine the year and day to get the value for JulianDate.
JulianDate = DateYear & JulianDay

NormalToJulian = JulianDate
End Function

------------------------------------------------
Second function converts Julian to Normal 990312 to 12/03/1999

Sub Convert_date()
Dim dtmNewDate As Date
Dim strJulianDate As String
strJulianDate = wrkRqmtDate
dtmNewDate = DateSerial(Left$(strJulianDate, 2), 1, 1)
dtmNewDate = DateAdd("d", Val(Right$(strJulianDate, 3)) - 1, dtmNewDate)
wrkRqmtDate = ""
wrkRqmtDate = Format(dtmNewDate, "mm/dd/yyyy")
End Sub
------------------------------------------------
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Look at DateSerial and DatePart.

Syntax

DateSerial(year, month, day)

The DateSerial function syntax has these named arguments:

Part Description
year Required; Integer. Number between 100 and 9999, inclusive, or a numeric expression.
month Required; Integer. Any numeric expression.
day Required; Integer. Any numeric expression.

DatePart(interval, date[,firstdayofweek[, firstweekofyear]])

The DatePart function syntax has these named arguments:

Part Description
interval Required. String expression that is the interval of time you want to return.
date Required. Variant (Date) value that you want to evaluate.
firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.
firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.


Settings

The interval argument has these settings:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top