Jump to content

Query Problem -Datetime = Date


karassik

Recommended Posts

Hello All,

 

Thanks for looking at this.

 

Take a look then I\'ll tell you the problem.

 

SELECT idclinic_dblog, date_dblog, SUM(charges_dblog), SUM(pmnt_dblog), SUM(adjmnts_dblog)

FROM dlybatchlog_dblog

WHERE date_dblog =\'\".$tmpDate.\"\'

GROUP BY idclinic_dblog

 

My problem is that date_dblog is a datetime field and I would like to sort by idclinic and todays date. $tmpDate is todays date as \"m-d-Y\" not sure if I have to use \"Y-m-d\", but that is the part I am having problems with. Do I first have to convert date_dblog to the format that I am comparting it to in the WHERE? OR?

 

Thanks.

 

Nishan

Link to comment
Share on other sites

So this worked perfectly until I added the $_SESSION portion.

 

SELECT idclinic_dblog, idcon_dblog, DATE_FORMAT(date_dblog,\'%m-%d-%Y\') as date_dblog, SUM(charges_dblog) as charges, SUM(pmnt_dblog) as payments, SUM(adjmnts_dblog) as adjustments

FROM dlybatchlog_dblog

GROUP BY date_dblog

HAVING date_dblog = DATE_FORMAT(now(),\'%m-%d-%Y\') AND idcon_dblog = \"\'.$_SESSION[\'KT_id_MSSIntranet\'].\'\"

 

I know that $_SESSION[\'KT_id_MSSIntranet\'] holds a number. Am I not using the correct Syntax? I tried a WHERE idcon_dblog = \"\'.$_SESSION[\'KT_id_MSSIntranet\'].\'\" instead of the AND but received an error.

 

Any insights?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.