Help needed with saving today's date back to database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • immohito
    New Member
    • Jun 2012
    • 6

    Help needed with saving today's date back to database.

    My echo $update_sql statement shows this

    UPDATE projects SET dex='{FD35CF46-D1F4-A05F-D4C6-16CF86A2E05F}', Name='h', Designation='f' , Phone=59, PMC=1, Quality=1, Progress=1, Issues=1, Responsiveness =1, Commitments=1, Safety=1, SLevel=1, Total=8, Improvement='No comment for now', Future='N', Date=2012/06/21 WHERE dex='{135C2B55-B95D-786D-9CBD-9563B3AF04B3}'

    The date shown here is the current date. However, the date stored in my database is 0000-00-00. what could be wrong? I am sanitizing the date as date type.

    sanitize($date, "date");

    I am using the $date=date(Y/m/d) to get today's date.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It depends on the DBMS you're using. But if it's access, dates have to be surrounded by hash (#) symbols. If it's SQL Server, you use single quotes. If it's DB2, I believe you have to use single quotes and cast it to a date. If it's anything else, I don't know off the top of my head. What you have there is the number 2012 divided by 6 divided by 21.

    Comment

    Working...