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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Julian Date Formula

Status
Not open for further replies.

FrustratedAtWork

Technical User
Aug 28, 2001
3
CA
I've been given the task of updating a string value in a paradox 3.5 database. I have never used paradox before and am looking to make a variable = to the current julian date, plus the time. Right now the code I have to work with looks like this:
yr = Year(today())
If yr>1999
Then cent = 2000 cent1 = 2000
Else cent = 1900 cent1 = 1900
EndIf
days=TODAY()-dateval("1/1/"+strval(yr-cent1))+1
yr2=(yr-cent)*1000
tran1=yr2+days
tran2=strval(tran1)+":"+TIME()

All I want to do is make the tran2 value equal to todays julian date and the current system time.
EG. 24001:23:21
Does this make sense? Could there be a one or two line code that will convert the system time to a julian date, then add on the system time?
Please help!!!!!
 
It depends on what you want to do with this field, but as if is difficult to sort/select on this kind of field, you may be better advised to just have 2 fields one for date and another for time. If you actually want to use the date/time field for sorting, I suggest you create a calculated number field.

eg [DATE_SORT]= BaseDate + TODAY() + (TICKS()/MaxTicks)

BaseDate is any constant date you like, eg 1.1.2000, so the first part is the number of days after that date.
Ticks() returns the number of milliseconds after midnight, so MaxTicks = 1000*60*60*24 (milliseconds in a day) so the last bit is always a fraction. This field, being a number can easily be sorted. Put the date and time fields on the database as well and you can easily select records based on those fields.

But if you still want to format the date/time to
MMDDYY HH:MM

DateString = FIIL("0", 2-LEN(MONTH(Today())) +
STRVAL(MONTH(Today()) +
FIIL("0", 2-LEN(DAY(Today())) +
STRVAL(DAY(Today()) +
SUBSTR(YEAR(Today(), 3, 2) +
" " + TIME()

TIME() returns HH:MM:SS, so if you do not want the seconds, just assign this to an A12 field and it will be truncated.

The Fill("0") part of this zero fills incase of a 1 digit month or day so that it is always 6chars for the date.
Month(), Day(), Year() all return numbers, hence the need to convert to a string and Substr takes chars 3 and 4 from the year.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top