Post Reply 
Date Functions
01-19-2015, 08:25 PM (This post was last modified: 01-19-2015 09:20 PM by Dieter.)
Post: #14
RE: Date Functions
(01-19-2015 04:47 PM)Wolfgang Wrote:  You don't have to look back if you are using COBOL; it is imperative, procedural and, since 2002, object-oriented.

My last and only COBOL experience dates back to 1985. ;-)

(01-19-2015 04:47 PM)Wolfgang Wrote:  COBOL is primarily used in business, finance, and administrative systems for companies and governments....
You can i.e. use both COBOL and ORACLE, to handle a lot of data records in business environments. PASCAL is for teaching students and solving technical or scientific utilization.

I love PASCAL for its sheer elegance. I'm not a profossional programmer, I just love writing compact and elegant algorithms for mathematical applications. On the other hand I also like the challenges of more assembler-like languagues as they are used in classic HP RPN calculators. ;-)

(01-19-2015 04:47 PM)Wolfgang Wrote:  
Quote:YMD:=10000*Y+100*M+D; // build YYYYMMDD
Very good idea!!
Such as handling transition points, i will try code it.

There is a more elegant way that shines up in the last VBA example I posted. If the Julian day number is calculated anyway, you can also use it for comparing dates. The suggested version with a configurable transition point (via LastJulian and FirstGregorian) can be handled even simpler – like this:

Code:
Const LastJulian = 2299160           ' last Julian date = 04 Oct 1582

Function Date2JD(d, m, y)
If m < 3 Then m = m + 12: y = y - 1
JD = (1461 * (y + 4716)) \ 4 + (153 * (m + 1)) \ 5 + d - 1524
If JD > LastJulian Then              ' Gregorian date?
   JD = JD + 2 - y \ 100 + y \ 400   ' then adjust JD 
   If JD <= LastJulian Then JD = -1  ' error marker - undefined date within transition period
End If
Date2JD = JD
End Function

This version needs just one constant (LastJulian = Julian day number of the last date of the Julian calendar, here 2299160 = 4 Oct 1582). If the calculated JDN (according to the Julian calendar) is greater than this limit (i.e. the date belongs to the Gregorian period), it gets the Gregorian adjustment. If the new Gregorian JDN now is ≤ LastJulian, the entered date was within the transition period (here 5...14 Oct 1582) and thus is undefined.

(01-19-2015 04:47 PM)Wolfgang Wrote:  Thank u very much, dieter. Becaue of your prename, do you speak german? (PM).

You bet / aber klar doch. :-)
There is a substantial number of German speaking contributors here. But of course this is an international forum, so they all resort to today's lingua franca. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Date Functions - Thomas_Sch - 05-08-2014, 12:49 PM
RE: Date Functions - Wolfgang - 09-19-2014, 05:55 PM
RE: Date Functions - Wolfgang - 01-14-2015, 10:17 PM
RE: Date Functions - ww63 - 01-15-2015, 08:16 AM
RE: Date Functions - Dieter - 01-15-2015, 01:21 PM
RE: Date Functions - Thomas_Sch - 01-15-2015, 08:35 AM
RE: Date Functions - ww63 - 01-15-2015, 08:38 AM
RE: Date Functions - Wolfgang - 01-15-2015, 03:35 PM
RE: Date Functions - Dieter - 01-15-2015, 07:49 PM
RE: Date Functions - Wolfgang - 01-15-2015, 10:37 PM
RE: Date Functions - Dieter - 01-16-2015, 08:40 AM
RE: Date Functions - Dieter - 01-18-2015, 06:25 PM
RE: Date Functions - salvomic - 04-09-2015, 03:03 PM
RE: Date Functions - Wolfgang - 01-19-2015, 04:47 PM
RE: Date Functions - Dieter - 01-19-2015 08:25 PM
RE: Date Functions - Wolfgang - 04-10-2015, 06:38 PM
RE: Date Functions - salvomic - 04-10-2015, 07:27 PM
RE: Date Functions - Wolfgang - 04-13-2015, 10:03 PM
RE: Date Functions - salvomic - 04-13-2015, 10:17 PM
RE: Date Functions - Wolfgang - 04-13-2015, 10:50 PM
RE: Date Functions - salvomic - 04-14-2015, 05:17 AM
RE: Date Functions - Thomas_Sch - 04-14-2015, 07:10 AM
RE: Date Functions - salvomic - 04-14-2015, 08:21 AM
RE: Date Functions - salvomic - 04-23-2016, 04:48 PM
RE: Date Functions - ggauny@live.fr - 07-05-2016, 07:42 AM
RE: Date Functions - ggauny@live.fr - 07-05-2016, 07:53 AM



User(s) browsing this thread: 1 Guest(s)