Getting Up Level
Leveling Database structure, is maight be not awkward for many programmer. I got problem when getting the up/upper level of some code. At last I found this way :
Suppose you have a data structure like this:
code varchar(10)
name varchar(100)
parent varchar(10)
level integer
code name parent level
------------------------------------
A1 AOne 1
A10 AOnezero A1 2
A11 AOneOne A1 2
A110 AOneOnezero A11 3
what is the up level 1 code of A110?
answer:
make the sql like this:
select * from table where level=1 and 'A110' like concat(code,'%')
Saturday, March 3, 2007
Getting Up Level
Diposting oleh
Jage
di
12:24 PM
0
komentar
Saturday, February 24, 2007
Date and Time Calculations (Firebird)
Date and Time Calculations
When doing arithmetic operations with TIMESTAMP values, Firebird works with them as decimal number, where
* the integral fraction is the number of days
* the decimal fraction is the part of a day
For example:
* Two days: 2.0
* One hour: 1.0/24.0
* One minute: 1.0/1440.0
* One second: 1.0/86400.0
Extracting the smaller units from a TIMESTAMP value:
* Number of seconds: VALUE*86400.0
* Number of minutes: VALUE*1440.0
* Number of hours: VALUE*24.0
Don't forget the decimal point in the numbers (e.g. 1.0), otherwise the result will be integer. I spent a lot time debugging a calculation that didn't work because I was dividing by an integer. Since that time, I remember.
Posted by Dan : 2:04 PM
---------------
firebird:
tgl jam server sekarang : current_timestamp
tgl : CAST ('today' AS TIMESTAMP)
jam : extract(hour from current_timestamp)||':'||extract(minute from current_timestamp)||':'||extract(second from current_timestamp)
Diposting oleh
Jage
di
1:21 PM
1 komentar
Categorys: Firebird