Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:05:21+00:00 2026-06-14T17:05:21+00:00

I have a query that gives me a unix timestamp calculated selecting the datetime

  • 0

I have a query that gives me a unix timestamp calculated selecting the datetime value of a table field and then adding another value of the table. The query is something like the following:

SELECT UNIX_TIMESTAMP(DATE_ADD(mydatetimefield, INTERVAL m.myfield1 + m.myfield2 MINUTE)) FROM mytable AS m

this query executes correctly from phpMyAdmin but when I try to use it with the createQueryBuilder method of Doctrine 2 I get an error at “myfield”. It seems that it doesn’t support a computed value after the INTERVAL keyword

Error: Expected Doctrine\ORM\Query\Lexer::T_COMMA, got 'm'

how can I then get the same query result by using doctrine? I use the querybuilder because I have some named parameters

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:05:22+00:00Added an answer on June 14, 2026 at 5:05 pm

    By default Doctrine does not support all the functions of a specific vendor, such as the DATE_ADD. However, you can use custom defined functions. That link has an example specifically for date add.

    Extending DQL in Doctrine 2: User-Defined Functions

    The other option, depending on the complexity of the query, is just to handle this in the application code. if your mydatetimefield is actually a datetime, Doctrine will convert that to a php DateTime in the returned object.

    $myDateTimeField = $object->getMyDateTimeField();
    $myDateTimeField->add(new DateInterval( $object->getMyField1() + $object->getMyField2() . 'M'));
    

    Lastly, you could always use dbal as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that I'd like to change so that it gives me
I have a query that successfully grabs the unique products from my products table
I have query that gives back results like this: Client1 Product1 $500 Client1 Product2
I have a query that gives me all customer's and their last three order
I'm trying to build a jpql query that gives me the average value in
I have the following query that gives me an extract (I am putting this
I have a sql query that gives me array in following format. Basically the
I have a working query that gives me the maxdate: SELECT a.client_id AS client_id
I have a query that gives me this result: |SystemName |SystemDescription |CertificateType |CertName |CertDate
Well after much messing about I have finally got a query that gives sales

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.