| |
|
|
Torben Nissen | this small Program accounts, How old one in years is.
'A small example, How to the old in years to charge can (ex Profan X2).
'of Torben Nissen
'16.04.2015
Declare aktuellesjahr!,aktuellermonat!,aktuellertag!
Declare date of birth$,date of birth!,year of birth!,geburtsmonat!,birthday!
Declare old!,old$
aktuellesjahr!=@dt("getYear", !now)
aktuellermonat!=@dt("getMonth", !now)
aktuellertag!=@dt("getDay", !now)
geburtsdatum$="17.01.2000"
geburtsdatum!=@dt("setDate", date of birth$)
geburtsjahr!=@dt("getYear", date of birth!)
geburtsmonat!=@dt("getMonth", date of birth!)
geburtstag!=@dt("getDay", date of birth!)
Set("Decimals",0)
If (aktuellertag! < birthday!) And (aktuellermonat! = geburtsmonat!)
old! = aktuellesjahr! - year of birth! - 1
ElseIf (aktuellertag! > birthday!) And (aktuellermonat! = geburtsmonat!)
old! = aktuellesjahr! - year of birth!
ElseIf (aktuellertag! = birthday!) And (aktuellermonat! = geburtsmonat!)
old! = aktuellesjahr! - year of birth!
EndIf
If aktuellermonat! < geburtsmonat!
old! = aktuellesjahr! - year of birth! - 1
ElseIf aktuellermonat! > geburtsmonat!
old! = aktuellesjahr! - year of birth!
EndIf
alter$=old!
cls
Print "Alter: "+old$
WaitInput
End
|
|
|
| |
|
|
|
HofK | Can too in XProfan The long selection save?
In my Scopeland-proposition (Base SQL) could I knifflige functions by VB Skript einbetten. therefore the View source old on the actually day and Bestimmung whether less- or volljährig on this day. the Datumsformat is evident JJJJ.MM.TT
If I the place be, look I time, as with InfinityProfan looks.
The "Trick" stick in the addition the numerischen Ergebnisses the Vergleichs (datMT < gebMT) + ... according to Language must one means accurate look what there happens and possible yet explizite Wandlungen distinguished.
old on the actually day
function old(geb)
Dim dat, datJ, datMT, gebJ, gebMT
dat = DBToday
If Len(geb)>0 Then
datJ = Left(dat,4)
gebJ = Left(geb,4)
datMT = Mid(dat,6,5)
gebMT = Mid(geb,6,5)
old = (datMT < gebMT)+(datJ-gebJ)
End If
end function
less/Volljährig
function mv(geb)
Dim dat, datJ, datMT, gebJ, gebMT, old
dat = DBToday
If Len(geb)>0 Then
datJ = Left(dat,4)
gebJ = Left(geb,4)
datMT = Mid(dat,6,5)
gebMT = Mid(geb,6,5)
old = (datMT < gebMT)+(datJ-gebJ)
If old < 18 Then
mv = "m"
Else
mv = "v"
End If
End If
end function
|
|
|
| |
|
|
|
Jörg Sellmeyer | The Datumsfunktionen are something umständlich and kryptisch but give very plenty Nützliches since. straight with Datumsvergleichen, can itself the Aufdröseln in day, month, year save.
here a Altersermittlung, The says, whether I yet birthday have, already having or today have:
Randomize
Var birthday$ = Input$("Bitte date of birth eingeben","Mein Alter",Dt("GetDate",0,!Now - Rnd(20000)))
Var s$ = Left$(birthday$,6) + Str $(DT("getYear",!Now))'here supplant I simply The Jahreszahl the Geburtsjahres by the actually Jahreszahl
Var n% = Dt("CompareDate",!Now,Dt("SetDate",s$))
'loudly Help ought to SetDate the really automatically make, the functions but apparently not.
Var old% = Abs(DT("GetYear",!Now) - DT("GetYear",Dt("SetDate",birthday$)))
Select n%
CaseOf 1
print "Du are on the " + Left$(birthday$,6) + Str $(DT("getYear",!Now)) + " " + Str $(old%) + " become."
CaseOf 0
Print "Herzlichen Glückwunsch to that " + Str $(old%) + ". birthday!"
CaseOf -1
print "Du become on the " + Left$(birthday$,6) + Str $(DT("getYear",!Now)) + " " + Str $(old%)
EndSelect
Print
WaitInput
moreover here The suitable Error Message: [...] |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 04/17/15 ▲ |
|
|
|
|
HofK | for XProfan 11.2 had I the "Trick" something alter, less...
return -(datMT$ < gebMT$)+(datJ$-gebJ$)
then klappt's too, Test with festem date "2015.04.15".
Nachtrag: if len(geb$) > 0 was so only meaningfully with reference the Geb.-Datums from the data base, there the area too empty his could.
print old("1978.07.21")
waitinput
proc old
parameters geb$
declare dat$, datJ$, datMT$, gebJ$, gebMT$
dat$ = "2015.04.15"
datJ$ = left$(dat$,4)
gebJ$ = left$(geb$,4)
datMT$ = mid$(dat$,6,5)
gebMT$ = mid$(geb$,6,5)
// print (datMT$ > gebMT$)
return -(datMT$ > gebMT$)+(datJ$-gebJ$)
endproc
|
|
|
| |
|
|
|
HofK | with InfinityProfan could it then time so similar weg:
|
|
|
| |
|
|
|
HofK | |
|
| |
|
|