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

  • Home
  • SEARCH
  • 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 8882567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:36:42+00:00 2026-06-14T20:36:42+00:00

I am getting the current system time with the following query select cast(DATEPART(hh,getdate()) as

  • 0

I am getting the current system time with the following query

select cast(DATEPART(hh,getdate()) as varchar)+ ':'+ cast(DATEPART(n,getdate()) as varchar)

Now how do I compare this current system time with a time field to see which is larger?

 -----------------------
 declare    @time1  datetime,
            @time2  datetime

 select  @time1 = '20060701 02:27:35.35',
         @time2 = getdate()

 select tm1, tm2,
        case    
         when tm1 = tm2 then 'tm1 = tm2' 
         when tm1 > tm2 then 'tm1 > tm2'
    else        'tm1 < tm2'
    end as [TimeDiff]
 from
 (
     select dateadd(day, -datediff(day, 0, @time1), @time1) as tm1,
            dateadd(day, -datediff(day, 0, @time2), @time2) as tm2
 ) t

 -----------------------

The time field has time in the following format

     0400
     0415
     0430

I see this supporting Function. Now how do I alter the @time1 part to “select time from table”

Thanks

  • 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-14T20:36:44+00:00Added an answer on June 14, 2026 at 8:36 pm

    try this:

    select case when cast(cast(DATEPART(hh,getdate()) as varchar)+ ':'+ cast(DATEPART(n,getdate()) as varchar) as datetime) >
           cast(left('0415',2)+':'+right('0415',2) as datetime) then 'greter' else 'lesser'
           end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written this code to convert the current system date and time to
I am using the boost library for getting the current system time and my
I tried below snippet I'm getting current date and time of system instead of
i keep getting this error, The current value 'String.Empty' type is not compatible with
Can anyone help me getting started with this? We have a current keygen for
I'm having a hard time getting this working in C++, I've managed it in
When I am printing the date //getting the current date and time self.date =
I keep getting the following error message at compile time: The name 'Message' does
I am fetching the Year of the Current device time with this code: Calendar
I'm trying to extract boot time by getting current time SYSTEMTIME structure, then converting

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.