如何更改数据库日期顺序?

时间:2015-02-05 12:52:36

标签: sql asp.net vb.net

string iadeTarihi=Fonksiyon.changeDateToString(DateTime.Today.AddDays(-15).ToShortDateString());

string sorgu =" select K.ID,K.BARKOD,K.AD,K.YAZAR,U.AD +''+U.SOYAD AS ISIM, U.TC,KT.VERILIS_TARIHI,U.ID AS UYE_ID from KITAP_TAKIP AS KT, KITAPLAR AS K, UYELER AS U WHERE"
    +"KT.KITAP_ID = K.ID AND KT.IADE_TARIHI ='' AND U.ID = KT.UYE_ID AND KT.VERILIS_TARIHI <'+ iadeTarihi "'";

我需要更改KT.VERILIS_TARIHI(DESC)

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我希望我能正确理解你。 你想要一个SQL查询和一个日期转换 - 15天?

这里是VB

Dim sorgu As String = "" & _
"SELECT " & _
"   K.ID, " & _
"   K.BARKOD, " & _
"   K.AD, " & _
"   K.YAZAR, " & _
"   U.AD + '' + U.SOYAD AS ISIM, " & _
"   U.TC, " & _
"   KT.VERILIS_TARIHI, " & _
"   U.ID AS UYE_ID " & _
"FROM KITAP_TAKIP AS KT, KITAPLAR AS K, UYELER AS U " & _
"WHERE KT.KITAP_ID = K.ID AND IsNull(KT.IADE_TARIHI, '') = '' AND U.ID = KT.UYE_ID AND KT.VERILIS_TARIHI < Convert(DATE, DateAdd(Day, -15, GetDate())) " & _
"ORDER BY KT.VERILIS_TARIHI DESC "

查询本身:

SELECT 
    K.ID, 
    K.BARKOD, 
    K.AD, 
    K.YAZAR, 
    U.AD + '' + U.SOYAD AS ISIM, 
    U.TC, 
    KT.VERILIS_TARIHI, 
    U.ID AS UYE_ID 
FROM KITAP_TAKIP AS KT, KITAPLAR AS K, UYELER AS U 
WHERE KT.KITAP_ID = K.ID 
  AND IsNull(KT.IADE_TARIHI, '') = '' 
  AND U.ID = KT.UYE_ID 
  AND KT.VERILIS_TARIHI < Convert(DATE, DateAdd(Day, -15, GetDate())) 
ORDER BY KT.VERILIS_TARIHI DESC