row = db((db.lease.unit == 35) & (db.lease.tenant == 27)).select(orderby=~db.lease.sewa_akhir).first()
sewa_akhir = row.sewa_akhir
tgl_masuk = row.tgl_masuk
form.vars.tgl_masuk = tgl_masuk #ini memasukkan ke fieldform
return dict(sewa_akhir=sewa_akhir,tgl_masuk=tgl_masuk)
- Perhatikan tilde di orderby
- perhatikan .first()
di view tinggal memasukkan {{=sewa_akhir}}
Update Tanggal
query = (db.unit.id == request.vars.unit)
set = db(query).update(sewa_akhir=request.vars.sewaakhir)
Menambah hari ke sebuah tanggal
dd = (datetime.datetime.now() + datetime.timedelta(days=10)).strftime("%Y-%m-%d")
return dict(dd=dd)
kode get json
http://127.0.0.1:8000/JPM/lease/getlast.json?unit=36&tenant=28
di controller:
def getlast():
row = db((db.lease.unit == 31) & (db.lease.tenant == 23)).select(orderby=~db.lease.sewa_akhir).first()
return dict(sewa_akhir=row.sewa_akhir,sewa_awal=row.sewa_awal)
Menambah hari ke sebuah tanggal
dd = (datetime.datetime.now() + datetime.timedelta(days=10)).strftime("%Y-%m-%d")
return dict(dd=dd)
kode get json
http://127.0.0.1:8000/JPM/lease/getlast.json?unit=36&tenant=28
di controller:
def getlast():
row = db((db.lease.unit == 31) & (db.lease.tenant == 23)).select(orderby=~db.lease.sewa_akhir).first()
return dict(sewa_akhir=row.sewa_akhir,sewa_awal=row.sewa_awal)
0 komentar:
Posting Komentar