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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:17:51+00:00 2026-06-06T19:17:51+00:00

I need two comparisons in my Sql server, One between Dates and One between

  • 0

I need two comparisons in my Sql server, One between Dates and One between Times. I’m using C# and Sql Server and Linq-to-sql. I want to store two time fields (Enter-Time, Exit-Time). Now I want to get the difference (e.g. 12:30 , 18:15 the difference is 5:45). What Data Type should I use? I have the same issue with Dates, I want to get the difference of two Dates but “DateTime” Data Type stores redundant data about time, I just need date. I want the easiest way with the least code possible. I’m currently saving like this “1045” when I fetch it I add a “:” to the middle and it becomes “10:45” and there are lot’s of problems this way.

  • 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-06T19:17:52+00:00Added an answer on June 6, 2026 at 7:17 pm

    If you need to store dates, you can use the date datatype. Similarly for times, you can use the time datatype.

    To compute the difference, you can use the DATEDIFF() sql function that returns the difference between two dates: http://msdn.microsoft.com/en-us/library/ms189794.aspx

    I would advise against storing your data as a string, int etc. Use the datatypes as they are intended.

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

Sidebar

Related Questions

I need to store two values, id and name returned from sql query into
I need to compare two columns in a sql table. The data in one
I have two SQL Server databases, and I need to write a script to
I need two methods one to encrypt and one to decrypt an xml file
I need two tables and two sets of fields, not the name of the
I've been using the MERGE operation in SQL Server 2008, but have now come
I need to perform a comparison between two XML documents. I've been looking at
I am in need of a query (or stored procedure rather) for SQL Server
I am in need of a query (or stored procedure rather) for SQL Server
I need to allow full-text searching on two fields that are concatenated together. In

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.