Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

broj dana minus nedjelje (Borland i baza)

[es] :: C/C++ programiranje :: broj dana minus nedjelje (Borland i baza)

[ Pregleda: 2972 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

DART_VEJDER
crna gora

Član broj: 58050
Poruke: 84
*.crnagora.net.



Profil

icon broj dana minus nedjelje (Borland i baza)25.04.2006. u 20:19 - pre 218 meseci
htio bih dobiti neki predlog od vas kako uraditi ovo:

imam jednu bazu podataka (koristim ADO ) i upisan datum u bazi kada je nesto dato nekome.

meni treba da kad kliknem na dugme da program uzme onaj datum iz baze i izracuna koliko je to dana bilo kod nekoga NE RACUNAJUCI NEDJELJE!!!!!

dakle ako je nesto uzeto npr. 01.06.2000 (npr. subota) a vraceno je 03.06.2000. ( ponedjeljak) to je zadrzano 1 dan....OK?

znaci treba mi vise kao neki algoritam kako to uraditi, a naravno i gotov kod bi bio super, to ne trebam pominjati....
normalno racun je: BROJ_DANA - BROJ_NEDJELJA , ali kako to uraditi kad samo imam datum kad je nesto uzeto i datum kad je nesto vraceno...

koje F-je u borlandu koristiti... cini mi se da ih ima dosta u borlandu koje rade sa vremenom...ima li neko vec predlog koja je za to...

hmmm... sad mi nesto pade na um da mozda u samom SQL-u nesto iskombinujem, ali uvijek je bolje u C++ - u kodu nesto uraditi...

dakle, davajte ljudi bilo kakav predlog da imate....

[Ovu poruku je menjao DART_VEJDER dana 25.04.2006. u 21:21 GMT+1]
kod žorža ti je ka' u banku!!
oko? sto ce ti oko??
 
Odgovor na temu

X Files
Vladimir Stefanovic
Pozarevac

SuperModerator
Član broj: 15100
Poruke: 4901
*.nat-pool.po.sbb.co.yu.

Jabber: xfiles@elitesecurity.org


+638 Profil

icon Re: broj dana minus nedjelje (Borland i baza)25.04.2006. u 21:51 - pre 218 meseci
Pozdrav,

Dakle, tebi treba neki algoritam koji ce iz ukupnog broja dana izmedju dva datuma
oduzeti dane koji su nedelje. Pretpostavljam da na netu ima dosta gotovog koda na
tu temu ( kljucne reci: "weekdays", "week days", "workdays", "working days"; naravno
uz neki dodatak, npr: "c++ source"), pa u svakom slucaju pogledaj sta kazu matematicari
sa svojim modulima i sl., da se rastereti sam algoritam.

Medjutim, U PRAKSI, trebalo bi tu i uracunati dane koji su STVARNO NERADNI i koji se
unose rucno, pa ti takvi algoritmi nece puno biti od pomoci.

Sto se tice Borland C++ Buildera, mislim da ima dosta funkcija i metoda koje se bave
vremenom i datumima, i to sam ostavio na dnu posta.

Evo ti jedan NETESTIRAN na brzinu napisan algoritam, koji ces morati da dopunis uslovima
koji ispituju drzavne praznike rucno, da bi sve to imalo smisla.

Code:

#include <DateUtils.Hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TDateTime D1 = Now(); // danasnji dan
   TDateTime D2 = D1+100; // jos 100 dana

   int radni_dani = 0;

   int ukupno_dana = DaysBetween( D2,D1 );

   for ( int i=0; i<ukupno_dana; i++ )
   {
      if ( DayOfWeek( D1++ ) != 1 ) // pogledaj Help, mislim da je (1) Nedelja
         ++radni_dani;
   }
   ShowMessage( radni_dani );
}


Konkretne cifre mozes pretvoriti u TDateTime objekat sa EncodeDate(), DecodeDate().


SPISAK FUNKCIJA:

CheckSqlTimeStamp
Checks whether a TSQLTimeStamp value represents a valid date and time.

CompareDate
Indicates the relationship between the date portions of two TDateTime values.

CompareDateTime
Indicates the relationship between two TDateTime values.

CompareTime
Indicates the relationship between the time portions of two TDateTime values.

CurrentYear
Returns current year.

Date
Returns the current date.

DateDelta constant
Specifies the difference between TDateTime and TTimeStamp values.

DateOf
Strips the time portion from a TDateTime value.

DateTimeToFileDate
Converts a TDateTime object to an OS timestamp.

DateTimeToSQLTimeStamp
Converts a TDateTime value to a TSQLTimeStamp value.

DateTimeToStr
Converts a TDateTime value to an AnsiString.

DateTimeToString
Converts a TDateTime object to an AnsiString using a specified Format.

DateTimeToSystemTime
Converts a TDateTime object into the Win32 API's _SYSTEMTIME type.

DateTimeToTimeStamp
Converts a TDateTime object into the corresponding TTimeStamp structure.

DateToStr
Converts a TDateTime object to an AnsiString object.

Day of week constants
Provide symbolic constants for ISO 8601-compliant day of the week values.

DayOf
Returns the day of the month represented by a TDateTime value.

DayOfTheMonth
Returns the day of the month represented by a TDateTime value.

DayOfTheWeek
Returns the day of the week represented by a TDateTime value.

DayOfTheYear
Returns the number of days between a specified TDateTime value and December 31 of the previous year.

DayOfWeek
Returns the day of the week for a specified date.

DaysBetween
Returns the number of whole days between two specified TDateTime values.

DaysInAMonth
Returns the number of days in a specified month of a specified year.

DaysInAYear
Returns the number of days in a specified year.

DaysInMonth
Returns the number of days in the month of a specified TDateTime value.

DaysInYear
Returns the number of days in the year of a specified TDateTime value.

DaySpan
Returns the number of days (including fractional days) between two specified TDateTime values.

DecodeDate
Returns Year, Month, and Day values for a TDateTime object.

DecodeDateDay
Returns the year and day of the year for a specified TDateTime object.

DecodeDateFully
Returns Year, Month, and Day, and Day-of-Week values for a TDateTime object.

DecodeDateMonthWeek
Returns the year, month, week of the month, and day of the week for a specified TDateTime object.

DecodeDateTime
Returns Year, Month, Day, Hour, Minute, Second, and Millisecond values for a TDateTime object.

DecodeDateWeek
Returns the year, week of the year, and day of the week for a specified TDateTime object.

DecodeDayOfWeekInMonth
For a given TDateTime value, returns the year, month, day of the week, and the count of that day of the week in the month.

DecodeTime
Breaks a TDateTime object into hours, minutes, seconds, and milliseconds.

EncodeDate; TryEncodeDate
Returns a TDateTime object that represents a specified Year, Month, and Day.

EncodeDateDay
Returns a TDateTime object that represents a specified day of the year for a specified year.

EncodeDateMonthWeek
Returns a TDateTime object that represents a specified day of a specified week in a specified month and year.

EncodeDateTime
Returns a TDateTime object that represents a specified year, month, day, hour, minute, second, and millisecond.

EncodeDateWeek
Returns a TDateTime object that represents a specified day of a specified week in a specified year.

EncodeDayOfWeekInMonth
Returns a TDateTime object that represents a specified occurrence of a day of the week within a specified month and year.

EncodeTime;TryEncodeTime
Returns a TDateTime object for a specified Hour, Min, Sec, and MSec.

EndOfADay
Returns a TDateTime object that represents the last millisecond of a specified day.

EndOfAMonth
Returns a TDateTime object that represents the last millisecond of the last day of a specified month.

EndOfAWeek
Returns a TDateTime object that represents the last millisecond of a specified day of a specified week.

EndOfAYear
Returns a TDateTime object that represents the last millisecond of a specified year.

EndOfTheDay
Returns a TDateTime object that represents the last millisecond of the day identified by a specified TDateTime object.

EndOfTheMonth
Returns a TDateTime object that represents the last millisecond of the last day of the month identified by a specified TDateTime object.

EndOfTheWeek
Returns a TDateTime object that represents the last millisecond of the last day of the week identified by a specified TDateTime object.

EndOfTheYear
Returns a TDateTime object that represents the last millisecond of the last day of the year identified by a specified TDateTime object.

FormatDateTime
Formats a TDateTime object.

HourOf
Returns the hour of the day represented by a TDateTime value.

HourOfTheDay
Returns the hour of the day represented by a TDateTime value.

HourOfTheMonth
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the month.

HourOfTheWeek
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the week.

HourOfTheYear
Returns the number of hours between a specified TDateTime value and 12:00 AM of the first day of the year.

HoursBetween
Returns the number of whole hours between two specified TDateTime values.

HourSpan
Returns the number of Hours (including fractional Hours) between two specified TDateTime values.

IncAMonth
Increments date data by one month.

IncDay
Returns a date shifted by a specified number of days.

IncHour
Returns a date/time value shifted by a specified number of hours.

IncMilliSecond
Returns a date/time value shifted by a specified number of milliseconds.

IncMinute
Returns a date/time value shifted by a specified number of minutes.

IncMonth
Returns a date shifted by a specified number of months.

IncSecond
Returns a date/time value shifted by a specified number of seconds.

IncWeek
Returns a date shifted by a specified number of weeks.

IncYear
Returns a date shifted by a specified number of years.

IsInLeapYear
Indicates whether a specified TDateTime value occurs in a leap year.

IsLeapYear
Indicates whether a specified year is a leap year.

IsPM
Indicates whether the time portion of a specified TDateTime value occurs after noon.

IsSameDay
Indicates whether a specified TDateTime value occurs on a the same day as a criterion date.

IsToday
Indicates whether a specified TDateTime value occurs on the current date.

IsValidDate
Indicates whether a specified year, month, and day represent a valid date.

IsValidDateDay
Indicates whether a specified year and day of the year represent a valid date.

IsValidDateMonthWeek
Indicates whether a specified year, month, week of the month, and day of the week represent a valid date.

IsValidDateTime
Indicates whether a specified year, month, day, hour, minute, second, and millisecond represent a valid date and time.

IsValidDateWeek
Indicates whether a specified year, week of the year, and day of the week represent a valid date.

IsValidTime
Indicates whether a specified hour, minute, second, and millisecond represent a valid date and time.

MilliSecondOf
Returns the millisecond of the second represented by a TDateTime value.

MilliSecondOfTheDay
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same day.

MilliSecondOfTheHour
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same hour.

MilliSecondOfTheMinute
Returns the number of milliseconds between a specified TDateTime value and the beginning of the same minute.

MilliSecondOfTheMonth
Returns the number of milliseconds between a specified TDateTime value and the beginning of the month.

MilliSecondOfTheSecond
Returns the millisecond of the second represented by a TDateTime value.

MilliSecondOfTheWeek
Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the week.

MilliSecondOfTheYear
Returns the number of milliseconds between a specified TDateTime value and 12:00:00:00 AM of the first day of the year.

MilliSecondsBetween
Returns the number of milliseconds between two specified TDateTime values.

MilliSecondSpan
Returns the number of milliseconds between two specified TDateTime values.

MinuteOf
Returns the minute of the hour represented by a TDateTime value.

MinuteOfTheDay
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the same day.

MinuteOfTheHour
Returns the number of minutes between a specified TDateTime value and the beginning of the same hour.

MinuteOfTheMonth
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the month.

MinuteOfTheWeek
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the week.

MinuteOfTheYear
Returns the number of minutes between a specified TDateTime value and 12:00 AM of the first day of the year.

MinutesBetween
Returns the number of minutes between two specified TDateTime values.

MinuteSpan
Returns the number of minutes, including fractions thereof, between two specified TDateTime values.

MonthOf
Returns the month of the year represented by a TDateTime value.

MonthOfTheYear
Returns the month of the year represented by a TDateTime value.

MonthsBetween
Returns the approximate number of months between two specified TDateTime values.

MonthSpan
Returns the approximate number of months, including fractions, between two specified TDateTime values.

MSecsToTimeStamp
Converts a specified number of milliseconds into a TTimeStamp value.

Now
Returns the current date and time.

NthDayOfWeek
Returns which occurrence of its weekday a specified TDateTime value represents.

NullSQLTimeStamp constant
Represents a NULL TSQLTimeStamp value.

RecodeDate
Replaces the date portion of a specified TDateTime value.

RecodeDateTime
Selectively replaces parts of a specified TDateTime value.

RecodeDay
Replaces the day of the month for a specified TDateTime value.

RecodeHour
Replaces the hour of the day for a specified TDateTime value.

RecodeMilliSecond
Replaces the millisecond of the second for a specified TDateTime value.

RecodeMinute
Replaces the minute of the hour for a specified TDateTime value.

RecodeMonth
Replaces the month of the year for a specified TDateTime value.

RecodeSecond
Replaces the second of the minute for a specified TDateTime value.

RecodeTime
Replaces the time portion of a specified TDateTime value.

RecodeYear
Replaces the year for a specified TDateTime value.

ReplaceDate
Replaces the date portion of a TDateTime value with a specified date.

ReplaceTime
Replaces the time portion of a TDateTime value with a specified time.

SameDate
Indicates whether two TDateTime values represent the same year, month, and day.

SameDateTime
Indicates whether two TDateTime values represent the same year, month, day, hour, minute, second, and millisecond.

SameTime
Indicates whether two TDateTime values represent the same time of day, ignoring the date portion.

SecondOf
Returns the second of the minute represented by a TDateTime value.

SecondOfTheDay
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the same day.

SecondOfTheHour
Returns the number of seconds between a specified TDateTime value and the beginning of the same hour.

SecondOfTheMinute
Returns the number of seconds between a specified TDateTime value and the beginning of the same minute.

SecondOfTheMonth
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM on the first day of the month.

SecondOfTheWeek
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM of the first day of the week.

SecondOfTheYear
Returns the number of seconds between a specified TDateTime value and 12:00:00 AM on the first day of the year.

SecondsBetween
Returns the number of seconds between two specified TDateTime values.

SecondSpan
Returns the number of seconds (including fractions thereof) between two specified TDateTime values.

SQLDayOfWeek
Indicates the day of the week when a specified TSQLTimeStamp value occurs.

SQLTimeStampToDateTime
Converts a TSQLTimeStamp value to a TDateTime value.

SQLTimeStampToStr
Converts a TSQLTimeStamp value to a string.

StartOfADay
Returns a TDateTime object that represents 12:00:00:00 AM on a specified day.

StartOfAMonth
Returns a TDateTime object that represents 12:00:00:00 AM on the first day of a specified month.

StartOfAWeek
Returns a TDateTime object that represents 1the first moment on a specified day of a specified week.

StartOfAYear
Returns a TDateTime object that represents the first moment on the first day of a specified year.

StartOfTheDay
Returns a TDateTime object that represents 12:00:00:00 AM on the day identified by a specified TDateTime object.

StartOfTheMonth
Returns a TDateTime object that represents 12:00:00:00 AM on the first day of the month identified by a specified TDateTime object.

StartOfTheWeek
Returns a TDateTime object that represents 12:00:00:00 AM on the first day of the week identified by a specified TDateTime object.

StartOfTheYear
Returns a TDateTime object that represents 12:00:00:00 AM on the first day of the year identified by a specified TDateTime object.

StrToDate
Converts an AnsiString object to a TDateTime object.

StrToDateDef
Converts an AnsiString object to a TDateTime object, with error default.

StrToDateTime
Converts an AnsiString object to a TDateTime object.

StrToDateTimeDef
Converts an AnsiString object to a TDateTime object with error default.

StrToSQLTimeStamp
Converts a string to a TSQLTimeStamp value.

StrToTime
Converts an AnsiString object to a TDateTime object.

StrToTimeDef
Converts an AnsiString object to a TDateTime object with error default.

SystemTimeToDateTime
Converts a _SYSTEMTIME value into a TDateTime objectvalue.

Time
Returns the current time.

TimeOf
Strips the date portion from a TDateTime value.

TimeStampToDateTime
Converts a TTimeStamp value into the corresponding TDateTime object.

TimeStampToMSecs
Converts a TTimeStamp value into an absolute number of milliseconds.

TimeToStr
Returns an AnsiString that represents a TDateTime object.

Today
Returns a TDateTime value that represents the current date.

Tomorrow
Returns a TDateTime value that represents the following day.

TryEncodeDateDay
Calculates the TDateTime value that represents a specified day of the year for a specified year.

TryEncodeDateMonthWeek
Calculates the TDateTime value that represents a specified day of a specified week in a specified month and year.

TryEncodeDateTime
Calculates the TDateTime value that represents a specified year, month, day, hour, minute, second, and millisecond.

TryEncodeDateWeek
Calculates the TDateTime value that represents a specified day of a specified week in a specified year.

TryEncodeDayOfWeekInMonth
Calculates a TDateTime object that represents a specified occurrence of a day of the week within a specified month and year.

TryRecodeDateTime
Selectively replaces parts of a specified TDateTime value.

TryStrToDate
Converts an AnsiString object to a TDateTime object, with Boolean success code.

TryStrToDateTime
Converts an AnsiString object to a TDateTime object with Boolean success code.

TryStrToSQLTimeStamp
Converts a string to a TSQLTimeStamp value.

TryStrToTime
Converts an AnsiString object to a TDateTime object with error default.

UnixDateDelta constant
Specifies the difference between TDateTime and TIME_T values.

WeekOf
Returns the week of the year represented by a TDateTime value.

WeekOfTheMonth
Returns the week of the month represented by a TDateTime value.

WeekOfTheYear
Returns the week of the year represented by a TDateTime value.

WeeksBetween
Returns the number of whole weeks between two specified TDateTime values.

WeeksInAYear
Returns the number of weeks in a specified year.

WeeksInYear
Returns the number of weeks in the year of a specified TDateTime value.

WeekSpan
Returns the number of weeks (including fractional weeks) between two specified TDateTime values.

WithinPastDays
Indicates whether two dates are within a specified number of days of each other.

WithinPastHours
Indicates whether two date/time values are within a specified number of hours of each other.

WithinPastMilliSeconds
Indicates whether two date/time values are within a specified number of milliseconds of each other.

WithinPastMinutes
Indicates whether two date/time values are within a specified number of minutes of each other.

WithinPastMonths
Indicates whether two date/time values are within a specified number of months of each other.

WithinPastSeconds
Indicates whether two date/time values are within a specified number of seconds of each other.

WithinPastWeeks
Indicates whether two date/time values are within a specified number of weeks of each other.

WithinPastYears
Indicates whether two date/time values are within a specified number of years of each other.

YearOf
Returns the year represented by a TDateTime value.

YearsBetween
Returns the approximate number of years between two specified TDateTime values.

YearSpan
Returns the approximate number of years (including fractions thereof) between two specified TDateTime values.

Yesterday
Returns a TDateTime value that represents the preceding day.
 
Odgovor na temu

DART_VEJDER
crna gora

Član broj: 58050
Poruke: 84
*.crnagora.net.



Profil

icon Re: broj dana minus nedjelje (Borland i baza)25.04.2006. u 22:59 - pre 218 meseci
hvala ti X Files, stvarno si kralj...

nadam se da je to to sto sam trazio....
kod žorža ti je ka' u banku!!
oko? sto ce ti oko??
 
Odgovor na temu

[es] :: C/C++ programiranje :: broj dana minus nedjelje (Borland i baza)

[ Pregleda: 2972 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.