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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:43:23+00:00 2026-06-13T05:43:23+00:00

i have a time clock application that registers employes Attendance at work, i was

  • 0

i have a time clock application that registers employes Attendance at work,

i was trying to set the visibility of “Enter” imageButton
(entrance e.g “Timein” field ) to hidden based on a query

so if there was no timeout in last record that has a TimeIn for the current UserId then the Enter button will be hidden

this is the table : (tId is PK IDENTITY)

enter image description here

so based on those records for example , the last (top 1) is not signed out so the user will not get to see the Enter button, that allows user to sign in, cause there was no last action of TimeOut

working from asp.net C# code behind i was trying to work a solution using datedIff as a query :

but i guess i am missing something here

please don’t take it to account if this is the wrong approach i just wanted to show.. i did try though if there’s a better way to achive what i need then just disregard that query

select isnull((SELECT TOP 1 case when [TimeOut] is null then '' else convert(nvarchar,[TimeOut]) end FROM tblTime WHERE datediff(day,TimeOut,getdate())=0 and UserId =3571 ORDER BY tId DESC),'')
  • 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-13T05:43:24+00:00Added an answer on June 13, 2026 at 5:43 am

    This finds the record with the highest tid for the userId.

    SELECT CASE WHEN [TimeOut] IS NULL THEN '' ELSE CONVERT(NVARCHAR,[TimeOut]) END
      FROM tblTime
      WHERE tId = ( SELECT MAX(tId)
                      FROM tblTime
                      WHERE UserId = 3571
                   )
    

    but ids aren’t a good choice for getting the most recent record. Probably you want something more along these lines, but it depends on the meaning of the columns and if there could be duplicates…:

    SELECT CASE WHEN [TimeOut] IS NULL THEN '' ELSE CONVERT(NVARCHAR,[TimeOut]) end
      FROM tblTime
      WHERE UserId = 3571
        AND ActiveDate = ( SELECT MAX(ActiveDate)
                             FROM tblTime
                             WHERE UserId = 3571
                         )
    

    or you could put the subquery as part of the FROM clause.

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

Sidebar

Related Questions

In My application have time consuming process.There fore i try to do that operation
I'm trying to create an application similar to Visual Studio in that we have
I am writing a small application with clock that sicplay date and time with
I have JavaFX application, and I want to detect that some amount of time
I have a Swing application that deals with date and time, so a lot
For my Mac OSX application, I have a feature that removes the system clock
To start, here is what I have implemented already. Working* Windows Time Clock application
I am currently making a time-clock system that is inside of a custom-built application
It is important for my Android application that the phone clock is correctly set.
I want to have a clock showing current time and refreshes every second. The

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.