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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:53:18+00:00 2026-05-12T20:53:18+00:00

Using VB.NET and SQL Server 2005 I want to generate a date according to

  • 0

Using VB.NET and SQL Server 2005

I want to generate a date according to the given Outtime,

Am entering the value like

ID  Date       Intime   Outtime  Holiday

001 23-02-2009 08:00:00 17:00:00 no
001 24-02-2009 17:00:00 08:00:00 no
001 25-02-2009 10:00:00 16:00:00 no
001 26-02-2009 18:00:00 20:00:00 no
001 27-02-2009                   yes

Expected Output

Table1

ID  Date       Intime   Outtime  DateIn     Dateout

001 23-02-2009 08:00:00 17:00:00 23-02-2009 23-02-2009
001 24-02-2009 17:00:00 08:00:00 24-02-2009 25-02-2009
001 25-02-2009 10:00:00 16:00:00 25-02-2009 25-02-2009
001 26-02-2009 18:00:00 20:00:00 26-02-2009 27-02-2009
001 27-02-2009     -        -        -         -

…,

From the above table, DateIn column value should display same date column value, But Dateout column should display according to the Outtime.

In a first row – Intime is 08:00:00 and Outtime is 17:00:00, So Dateout should display the same date
In a second row – Intime is 17:00:00 and Outtime is 08:00:00, So DateOut should display the next day date.
In a third row – Intime is 10:00:00 and Outtime is 16:00:00, so Dateout should display the same date
In a fourth row – Intime is 18:00:00 and Outtime is 21:00:00, so Dateout should display the next day date.
In a fifth row – Holiday column value is yes, so it should not display any value in DateIn and DateOut

Dateout column should compare the Intime and Outtime value, if Outtime is less than Intime, Dateout column should display the next day date.

If Holiday = Yes then It should display as a blank column

For the above condition, How to make a sql query?

Whether it is possible in vb.net, which is faster sql query or vb.net code?

Need SQL Query or VB.NET code for the above condition.

  • 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-05-12T20:53:18+00:00Added an answer on May 12, 2026 at 8:53 pm

    This seems to work (note that my dates are in US format, since that’s where I am 🙂 ):

    create table times
       (
       Id             integer,
       stDate         datetime,
       InTime         datetime,
       OutTime        datetime,
       Holiday        varchar(3)
       )
    go
    
    insert into times values (001, '02-23-2009', '08:00:00', '17:00:00', 'no')
    insert into times values (001, '02-24-2009', '17:00:00', '08:00:00', 'no')
    insert into times values (001, '02-25-2009', '10:00:00', '16:00:00', 'no')
    insert into times values (001, '02-26-2009', '21:00:00', '20:00:00', 'no')
    insert into times values (001, '02-27-2009', null, null, 'yes')
    go
    
    select * from times
    go
    
    select
       t.Id,
       stDate,
       InTime,
       OutTime,
       case
          when Holiday = 'no' then stDate
          else null
       end       DateIn,
       case
          when InTime > OutTime and Holiday = 'no' then stDate + 1
          when InTime < OutTime and Holiday = 'no' then stDate
          else null
       end       DateOut
    from
       times t
    

    Results:

    Id         stDate                  InTime                  OutTime                 DateIn                  DateOut                 
    ---------- ----------------------- ----------------------- ----------------------- ----------------------- ----------------------- 
    1          2009-02-23 00:00:00.000 1900-01-01 08:00:00.000 1900-01-01 17:00:00.000 2009-02-23 00:00:00.000 2009-02-23 00:00:00.000 
    1          2009-02-24 00:00:00.000 1900-01-01 17:00:00.000 1900-01-01 08:00:00.000 2009-02-24 00:00:00.000 2009-02-25 00:00:00.000 
    1          2009-02-25 00:00:00.000 1900-01-01 10:00:00.000 1900-01-01 16:00:00.000 2009-02-25 00:00:00.000 2009-02-25 00:00:00.000 
    1          2009-02-26 00:00:00.000 1900-01-01 21:00:00.000 1900-01-01 20:00:00.000 2009-02-26 00:00:00.000 2009-02-27 00:00:00.000 
    1          2009-02-27 00:00:00.000 NULL                    NULL                    NULL                    NULL                    
    
    5 Row(s) affected
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 210k
  • Answers 210k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use GraphViz and connect it to your php… May 12, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer Okay, the best I can come up with so far… May 12, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer If you're sure you want to use GPB, then protobuf-actionscript3… May 12, 2026 at 9:54 pm

Related Questions

I am using VB.net (FormView and ObjectDataSource) and Sql Server 2005. I want to
I am using vb.net code and sql server 2005. I have textbox in my
I'm using SQL Server 2005, and I would like to know how to access
I have ALWAYS used the SQLDataSource to update my records in my SQL Server
I see this time and time again. The UAT test manager wants the new

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.