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 8800205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:31:31+00:00 2026-06-14T00:31:31+00:00

Basically I’d like to get this command to work: $sql = SELECT (EntryDate +

  • 0

Basically I’d like to get this command to work:

$sql = "SELECT (EntryDate + TotalTime) as DataLine FROM TimeSheet WHERE EmployeeID='AA01'";

EntryDate is in the database as a text, but TotalTime is a Number. I need to cast TotalTime as a text, because I’ve noticed if I combine two differing types of values, it just blanks out the output.

I know I’m supposed to use CAST(TotalTime as XXX) but I’m not sure what I can legally cast it to (char/nchar doesn’t seem to work, neither does string nor text). I always get an error of the form…

Syntax error (missing operator) in query expression '(EntryDate + CAST(TotalTime as string) as DataLine FROM TimeSheet WHERE EmployeeID='AA01''

Could I get some help? Thank you!

EDIT I would like to note this isn’t intended to add together the values of EntryDate and TotalTime together to produce a single value. I simply want it to give me the EntryDate value as well as the TotalTime value combined into a single line that would read something like:

“10/31/12 9.25”

EDIT AGAIN I’m sorry for not specifying before, I’m using MSSQL

  • 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-14T00:31:32+00:00Added an answer on June 14, 2026 at 12:31 am

    Try this instead:

    SELECT 
      CAST(EntryDate AS VARCHAR(25)) + CAST(TotalTime AS VARCHAR(10)) as DataLine 
    FROM TimeSheet 
    WHERE EmployeeID = 'AA01';
    

    However, if entrydate is a date and the int totaltime is a time, it may be better to consider converting them as a datetime object by adding them as a date part to the time part depending on the RDBMS you are using. And if possible use a DATETIME datatype to represent both date and time parts instead of two parts. Like so:

    SELECT DATEADD(hh, totaltime, entrydate)
    FROM TimeSheet
    WHERE EmployeeID = 'AA01';
    

    SQL Fiddle Demo

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

Sidebar

Related Questions

Basically from a database I am getting data that is formatted like this nameofproject101
Basically, I would like a brief explanation of how I can access a SQL
Basically I need to get older version of a file in the repository without
Basically from C++ FAQ I learned that: A virtual function allows derived classes to
Basically, I have a list of delivery checkboxes one for deliver to this address
Basically, I get the error: -[UIViewController donePress:]: unrecognized selector sent to instance 0x6a7f7c0 ***
Basically I saw this page THIS PAGE and if you scroll up and down
Basically, this is a noob question. Forgive. :( Every example in books or on
Basically this is a program which I take a text file with some code
Basically this function is meant to store the height value of the element that

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.