English
Source / code snippets

Datumsberechnung

 

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
 
04/16/15  
 




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

less/Volljährig
 
04/17/15  
 




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

 
04/18/15  
 




HofK
with InfinityProfan could it then time so similar weg:
print old("19781210")// date of birth in the Datenbankformat yyyymmdd

proc old(geb)

    var dat   = time(10)// 10: News date in the Datenbankformat yyyymmdd
    var datJ  = st(dat,1,4)// with Include possible left()
    var gebJ  = st(geb,1,4)
    var datMT = st(dat,1,4)// with Include possible mid()
    var gebMT = st(geb,5,4)
    // print (datMT < gebMT) // to that Test the possible numerischen Repräsentation of true
    // otherwise "wandeln"
    return -(datMT < gebMT)+(datJ-gebJ)// ev. then testing, less How with XProfan ???

endproc

 
04/20/15  
 




HofK
Klaus Hoffmeister (20.04.15)
with InfinityProfan could it then time so similar weg:



... and so see it objectively from: [...] 
 
11/10/15  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

8.759 Views

Untitledvor 0 min.
Erhard Wirth06/14/24
H.Brill11/11/22
p.specht11/20/21
E.T.11/20/21
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie