按经过时间php mssql server计算价格

I have a parking system and I try to make a php script to calculate price than print to POS printer.

I get the insterted time from mssql like : 2013-01-04 12:49:49

I would like to calculate the elapset time to timenow();

than set value like this in minutes:

if 30 = 0;
if 60 = 1;
if 120 = 2,50

...... and and :-)

is it possible?

Try this please using DATEDIFF:

   SELECT CASE `X.ElapsedTime` 
               WHEN  MOD 30 = 0 THEN 0
               WHEN MOD 60 = 0 THEN 1 
               WHEN MOD 120 = 0 THEN 2 
               ELSE Null END AS `ElapsedCount` 
   FROM (SELECT  DATEDIFF(mi, startime, GetDate()) AS `ElapsedTime`
   FROM yourtable) X;

Another approach would be (if you require you may round it up):

   SELECT (`X.ElapsedTime`/60 + '.' + `X.ElapsedTime` MOD 60) as `ElapsedCount`
   FROM (SELECT  DATEDIFF(mi, startime, GetDate()) AS `ElapsedTime`
   FROM yourtable) X;

Or using hh:

   SELECT  DATEDIFF(hh, startime, GetDate()) AS `ElapsedCount`
   FROM yourtable;

EDITING OP'S query in the comment to use JOINs

SELECT top 1 dbo.Partners.IdPartner AS pid, 
dbo.Partners.PartnerName AS name, dbo.Partners.MemberNumber AS nr, 
dbo.T_PAID_KARTE.MAGNETNA_COD, dbo.T_PAID_KARTE.ACTIVE AS active, 
dbo.T_PAID_KARTE.TYP AS cardnime, dbo.T_PAID_KARTE.ID_PAIDBY, 
dbo.T_LOGG.EXIT AS exittime, DATEDIFF(mi, exittime, GetDate()) AS ElapsedCount, 
dbo.T_LOGG.ID_PARTNER 
FROM dbo.Partners
INNER JOIN dbo.T_PAID_KARTE
ON 
INNER JOIN dbo.T_LOGG
ON 
;