| |
|
|
- Page 1 - |
|
Walter | Hi,
background: I parse a Text to Datumswerten (in DB-stature) and errechne from two Datumswerten The Day-difference .
Freeprofan 095, Prfrun32.exe
Set("ErrorLevel", 0)
declare date1$,date2$,Diff%
'Eingelesene values zB
Datum1$=20161001
Datum2$=20161030
'+----------------------------------------------
Proc DeltaTage_DB_Format
'+----------------------------------------------
'accounts amount of Meet between 2 Datumswerten
'Parameter: beginning, end in Datenbankformat
'Return difference days Integer
Parameters From$,To$
Return dt("DaysBetween", dt("setdate",DToC$(From$)), dt("setdate",DToC$(To$)))
endproc'DeltaTage_DB_Format
' Hauptprogramm
Diff% = DeltaTage_DB_Format(date1$,date2$)
messagebox(st$(diff%),"Differenz-Tage",0)
with input gültiger Datumswerte errechnet the program The difference. with fehlerhaftem Datumswert fractures "setdate" the program without Possibility of/ one reaction ex. gives it The Possibility, one date on validly To to check on, before one it uses?
LG
Walter |
|
|
| |
|
|
|
« this Posting watts as Solution marked. » |
|
Jörg Sellmeyer | i'd it so make:
Set("ErrorLevel", 0)
declare date1$,date2$,Diff%
'Eingelesene values zB
Datum1$=20161001
Datum2$=20161030
'+----------------------------------------------
Proc DeltaTage_DB_Format
'+----------------------------------------------
'accounts amount of Meet between 2 Datumswerten
'Parameter: beginning, end in Datenbankformat
'Return difference days Integer
Set("ErrorLevel", -1)
Parameters From$,To$
Var worth$ = dt("DaysBetween", dt("setdate",DToC$(From$)), dt("setdate",DToC$(To$)))
'print %error
If %Error > 0
'print "Fehler"
worth$ = "Fehler"
EndIf
Set("ErrorLevel", 0)
Return worth$
endproc'DeltaTage_DB_Format
' Hauptprogramm
Var Result$ = DeltaTage_DB_Format(date1$,date2$)
If Result$ = "Fehler"
'...
Else
diff% = Val(Result$)
'here then The further treatment
EndIf
Waitinput
|
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 11/03/16 ▲ |
|
|
|
|
|
Walter | Oho - trickreich! cordial Thanks! Walter |
|
|
| |
|
|
|
Michael W. | some routines from MwDate
Proc MakeFullYear
' filling the (possible) forgotten centenary on.
' Y = MakeFullYear( Y )
Parameters Y%
Declare ThisCentury%, ThisCenturyRange%
ThisCentury% = 20
ThisCenturyRange% = 29'2000 - 2029, otherwise 1930 - 1999
If Y% < 100
Casenote Between(ThisCenturyRange%,0,99) : ThisCenturyRange% = 29
Casenote Between(ThisCentury%,16,39) : ThisCentury% = Int(dt("GetYear",!now) / 100)
If Y% <= ThisCenturyRange%
' News year
Y% = Y% + (ThisCentury% * 100)
Else
' Vorjahr
Y% = Y% + ((ThisCentury% - 1) * 100)
EndIf
EndIf
Return Y%
ENDPROC
Proc LastDayInMonth
' supply whom last day the month's.
' Ultimo = LastDayInMonth( Mo, Y )
' -1 = Error
Parameters Mo%, Y%
Declare Leap%, Ultimo%, LDiM%[12]
LDiM%[0]=0:LDiM%[1]=31:LDiM%[2]=28:LDiM%[3]=31:LDiM%[4]=30:LDiM%[5]=31:LDiM%[6]=30
LDiM%[7]=31:LDiM%[8]=31:LDiM%[9]=30:LDiM%[10]=31:LDiM%[11]=30:LDiM%[12]=31
Ultimo% = -1
Case Y% < 100 : Y% = MakeFullYear(Y%)
Leap% = if((((Y% mod 4) = 0) and ((Y% mod 100) <> 0)) or ((Y% mod 400) = 0), 1, 0)' isLeapYear(Y)
Case Between(Mo%,1,12) : Ultimo% = LDiM%[Mo%] + if( (Mo% = 2) and (Leap% = 1), 1, 0)
Return Ultimo%
ENDPROC
Proc isValidDate
' checks day,month,year on Gültigkeit.
' ok = isValidDate(D,Mo,Y)
' 0 = invalid (false)
' 1 = valid (true)
Parameters D%,Mo%,Y%
Declare ok%
ok% = 0
Case Between(Y%,1600,3999, Mo%,1,12, D%,1,(LastDayInMonth(Mo%,Y%))) : Inc ok%
Return ok%
ENDPROC
Proc GetDayDB
' Zieht whom day a DB-date.
' Day = GetDayDB( DB )
Parameters DB%
Return DB% mod 100
ENDPROC
Proc GetMonthDB
' Zieht whom month a DB-date.
' Month = GetMonthDB( DB )
Parameters DB%
Return Int((DB% mod 10000) / 100
ENDPROC
Proc GetYearDB
' Zieht the year a DB-date.
' Year = GetYearDB( DB )
Parameters DB%
Return Int(DB% / 10000)
ENDPROC
Proc SetDB
' prepares from day,month,year one DB-date with Gültigkeitsprüfung.
' DB = SetDB(D,Mo,Y)
' -1 = Error
Parameters D%,Mo%,Y%
Declare DB%
DB% = -1
Case Y% < 100 : Y% = MakeFullYear(Y%)
Case isValidDate(D%,Mo%,Y%) : DB% = Y% * 10000 + Mo% * 100 + D%
Return DB%
ENDPROC
|
|
|
| |
|
|
|
Walter | Yes, the are very useful routines! have me otherwise because of the not integrally einfachen Using the new Datumsfunktionen additional with functions from prfdat32.dll right well beholfen. Thank you! Walter |
|
|
| |
|
|