Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge: Compute the number of Tuesdays since a given date
#8
I'm sorry Moneo i mess up thursday and tuesday ( :oops: )

But I hope this helps you.

Code:
DEFDBL A-Z
DECLARE FUNCTION JulianDate# (y%, m%, d%, ut%)

a = JulianDate#(1899, 12, 29, -3) '<-- este dia fue viernes
' para contar los martes habria que poner un miercoles
b = JulianDate#(2004, 6, 11, -3) '<-- ajustar fecha
dias = b - a

PRINT "Hoy es ";
SELECT CASE FIX(dias) MOD 7
  CASE 5: PRINT "miercoles"
  CASE 6: PRINT "jueves"
  CASE 0: PRINT "viernes"
  CASE 1: PRINT "sabado"
  CASE 2: PRINT "domingo"
  CASE 3: PRINT "lunes"
  CASE 4: PRINT "martes"
END SELECT

PRINT "Han pasado "; FIX(dias / 7); " jueves"

DEFSNG A-Z
FUNCTION JulianDate# (y%, m%, d%, ut%)
  DIM a#, b#, c#
  a# = FIX(7# * (y% + FIX((m% + 9#) / 12#)) / 4#)
  b# = FIX(3# * (FIX((y% + (m% - 9#) / 7#) / 100#) + 1) / 4#)
  c# = FIX(275 * m% / 9#) + d% + 1721028.5# + ut% / 24#
  JulianDate# = 367# * y% - a# - b# + c#
END FUNCTION

Also take a look at http://scienceworld.wolfram.com/astronom...nDate.html.
Reply


Messages In This Thread
Challenge: Compute the number of Tuesdays since a given date - by xhantt - 06-09-2004, 11:54 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)