Showing posts with label gratis. Show all posts
Showing posts with label gratis. Show all posts

Wednesday, June 26, 2013

Bruno mars Grenade

Easy come, easy go, that’s just how you live
Oh, take, take, take it all but you never give
Should’ve known you was trouble from the first kiss
Had your eyes wide open, why were they open?

Gave you all I had and you tossed it in the trash
You tossed it in the trash, you did
To give me all your love is all I ever asked
‘Cause what you don’t understand is

I’d catch a grenade for ya
Throw my hand on a blade for ya
I’d jump in front of a train for ya
You know I’d do anything for ya

I would go through all this pain
Take a bullet straight through my brain
Yes, I would die for you, baby
But you won’t do the same

No, no, no, no

Black, black, black and blue, beat me ’til I’m numb
Tell the devil I said, hey, when you get back to where you’re from
Mad women, bad women, that’s just what you are, yeah
You’ll smile in my face then rip the brakes out my car

Gave you all I had and you tossed it in the trash
You tossed it in the trash, yes, you did
To give me all your love is all I ever asked
‘Cause what you don’t understand is

I’d catch a grenade for ya
Throw my hand on a blade for ya
I’d jump in front of a train for ya
You know I’d do anything for ya

I would go through all this pain
Take a bullet straight through my brain
Yes, I would die for ya, baby
But you won’t do the same

If my body was on fire
Ooh, you’d watch me burn down in flames
You said you loved me, you’re a liar
‘Cause you never, ever, ever did, baby

But darling, I’d still catch a grenade for ya
Throw my hand on a blade for ya
I’d jump in front of a train for ya
You know I’d do anything for ya

I would go through all this pain
Take a bullet straight through my brain
Yes, I would die for you, baby
But you won’t do the same

No, you won’t do the same
You wouldn’t do the same
Ooh, you never do the same
No, no, no, no

Monday, June 24, 2013

Mencari Selisih Antara 2 Tanggal/DateTime pada SQL

Mencari Selisih Antara 2 Tanggal/DateTime pada SQL
13 Feb
SQL Server menyediakan Fungsi Tanggal untuk memanipulasi data jenis Datetime dengan menggunakan Operator Aritmatika.Sehingga kita lebih mudah dalam menghitung dan mencari selisih dari dua tanggal / DateTime. Misalnya kita ingin mencari berapa selisih antara tanggal ‘02-02-2012‘ dan ‘20-02-2012‘ maka hasilnya adalah ‘18 Hari .’
Nah, di SQL kita dipermudah dengan adanya fungsi tanggal tersebut.Adapun query yang digunakan untuk mencari selisih dari 2 datetime tersebut ialah DateDiff. DateDiff berfungsi untuk mencari selisih dua buah datetime.DateDiff bukan hanya digunakan untuk mencari selisih Hari tetapi juga bisa mencari selisih Bulan,dan Tahun.
Sintaks : DateDiff ( DatePart, Date1, Date2)
DatePart yaitu Interval DateTime yang kita ingin cari, misalnya Date, Month, Year
Pembahasan :
create table Transaksi (
Nama varchar (15), CheckIn datetime, CheckOut datetime
)
insert into Transaksi values (‘Budi’,’11/10/11′,’11/12/11′)
insert into Transaksi values (‘Rina’,’10/12/11′,’10/20/11′)
insert into Transaksi values (‘Danu’,’12/25/11′,’01/03/12′)
insert into Transaksi values (‘Satrya’,’01/10/11′,’01/15/11′)
insert into Transaksi values (‘Erni’,’02/05/11′,’02/08/11′)
Select * From Transaksi
Maka hasilnya akan seperti dibawah ini :
Lalu, untuk mencari berapa Hari Customer menginap kita gunakan fungsi DateDiff yang baru saja kita bahas tadi.
Select Customer, CheckIn, CheckOut, DateDiff (Day,CheckIn,CheckOut) as ‘Total Hari’
from Transaksi
Maka akan tampil seperti berikut :


Menghitung banyak hari
procedure TForm1.Button1Click(Sender: TObject);
var
  date1, date2: TDateTime;
  difference: Integer;
begin
  date1 := EncodeDate(2006, 01, 15);
  date2 := EncodeDate(2000, 01, 01);
  difference := trunc(date1) - trunc(date2);
  ShowMessage(IntToStr(difference));
end;


Tanggal terakhir
function LastDayOfCurrentMonth: TDate;
var
  y, m, d: Word;
begin
  DecodeDate(now, y, m, d);
  m := m + 1;
  if m  12 then
  begin
    y := y + 1;
    m := 1;
  end;
  Result := EncodeDate(y, m, 1) - 1;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(DateToStr(LastDayOfCurrentMonth));
end;

function GetDays(ADate: TDate): Extended;
var
  FirstOfYear: TDateTime;
begin
  FirstOfYear := EncodeDate(StrToInt(FormatDateTime('yyyy', now)) - 1, 12, 31);
  Result      := ADate - FirstOfYear;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  label1.Caption := 'Today is the ' + FloatToStr(GetDays(Date)) + '. day of the year';
end;



function CalculateAge(Birthday, CurrentDate: TDate): Integer;
var
  Month, Day, Year, CurrentYear, CurrentMonth, CurrentDay: Word;
begin
  DecodeDate(Birthday, Year, Month, Day);
  DecodeDate(CurrentDate, CurrentYear, CurrentMonth, CurrentDay);
  if (Year = CurrentYear) and (Month = CurrentMonth) and (Day = CurrentDay) then
  begin
    Result := 0;
  end
  else
  begin
    Result := CurrentYear - Year;
    if (Month > CurrentMonth) then
      Dec(Result)
    else
    begin
      if Month = CurrentMonth then
        if (Day > CurrentDay) then
          Dec(Result);
    end;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := Format('Your age is %d', [CalculateAge(StrToDate('01.03.1953'), Date)]);
end;