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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:47:16+00:00 2026-06-09T14:47:16+00:00

I have two columns in DB: StartDate (datetime column) and StartTime (nvarchar column). StartDate

  • 0

I have two columns in DB: StartDate (datetime column) and StartTime (nvarchar column).
StartDate contains date when event shoud start.
StartTime contains time when event should start. It is 24hour format (for example, 22:00 or 12:00).

I need to combine StartDate with StarTime to use it in WHERE clause and compare the result with variable. It would look like:

WHERE COMBINED_STARTDATE_WITH_STARTIME >= @DATETIME_VARIABLE

I am using SQL SERVER 2008.
This is existing DB design and would not like to change it. Probably, I can create third column and combine datetime + startdate into one column, but I am looking for another sollutions (that doesn’t touch database).

  • 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-09T14:47:17+00:00Added an answer on June 9, 2026 at 2:47 pm

    You can use something like this:

    WHERE 
    dateadd(minute, cast(right(starttime, 2) as int),
        dateadd(hour, cast(left(starttime, 2) as int), startdate)) >= @DATETIME_VARIABLE
    

    SQL Fiddle with DateTime Conversion

    In the event the start time is null then you can use IsNull() around the value:

    WHERE
    dateadd(minute, cast(right(isnull(starttime, 0), 2) as int),
        dateadd(hour, cast(left(isnull(starttime, 0), 2) as int), startdate)) >= @DATETIME_VARIABLE
    

    See SQL Fiddle with Demo

    Of course if you are using SQL Server 2008+ you can just cast your value as time:

    WHERE startdate + IsNull(StartTime, '00:00') >= @DATETIME_VARIABLE
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

I have a table called Sessions with two datetime columns: start and end. For
I have a table with two separate columns for date and time (SQL Server
I have the facts table with two date columns: StartDate and FinishDate: And I
I have table with two columns (startdate & enddate) and I have two submission
I have two columns. Column E extends up to 99504 (values) and column I
I have two columns. ColA and ColB contains char(10) with data 20090520 and 20090521.
I have two columns, #photos and #text . My #photos column is longer and
I have two columns in a QTreeWidget , one column represents a list of
I have two tables both of which have columns StartDate and EndDate. I'm trying
I have a table with column StartDate, I want to calculate the time difference

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.