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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:07:04+00:00 2026-05-13T16:07:04+00:00

Using VB.Net and SQL 2005 Table1 Name FromDate ToDate Sched1 20091201 20091231 Sched2 20090515

  • 0

Using VB.Net and SQL 2005

Table1

Name   FromDate ToDate

Sched1 20091201 20091231
Sched2 20090515 20090613
...,

In table2 i want to add a time for a date between the FromDate and ToDate

Table2

Name   Date     StartTime EndTime

Sched1 20091201  080000    120000
...,

In my application am using “AddTime” Button. In the click event i want to write a code for adding the time for the dates.

When I click ADDTime Button. It should check the max(date) in table2. Then it should show the next date of the max(date) in table2.

For Example

Select max(date) from table where name = 'Sched1'. 

It should show the next date means 20091202. because 20091201 Data is there.

There is no data in table2 for Sched2, So It should show the StartDate 20090515 from table1.

How to make a code or query for this condition?

Can any one give me a idea or samples 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-13T16:07:05+00:00Added an answer on May 13, 2026 at 4:07 pm

    I believe following query will do the task at hand.

    Select isnull(max(t2.date)+1,t1.FromDate) 
    from table1 t1 inner join table2 t2
    on t1.[Name] = t2.[Name]
    where t1.[name] = 'Sched1'
    

    The query is joining both the tables on Name, and after that it is checking that, is there any date present in Table2 for ‘Sched1’, if so it will return the max date +1 day, and if not it will return the FromDate from Table1 for ‘Sched1’.

    I’ll recommend you to read further on joins, you will not be able write but only the trivial queries without joins, further consider using integers for your keys.

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

Sidebar

Related Questions

Using SQL Server 2005, vb.net Table1 Name FromDate ToDate Raja 12/02/2010 14/02/2010 Ravi 14/02/2010
Using SQL Server 2005 and VB.Net Table1 ID Name Dept 001 Raja IT 002
What are some ideas (using .NET and SQL 2005) for implementing a service that
I am using .NET 2.0 and SQL Server 2005. For historical reasons, the app
I need to write a web application using SQL Server 2005, asp.net, and ado.net.
First some background: VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web
I am using VB.NET and SQL Server 2005 , and I want to write
I have a Windows .net application using SQL Server 2005 Express as database, which
I am using Sql Server 2005 and Vb Studios 2010 on a .net Framework
I am using sql server 2005 and .NET. I have a table with float

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.