Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am developing a web app for doctors, I want help for appointment scheduling I am confused how would i subtract or add time any suggestions
Posted
Comments
CHill60 4-Oct-14 13:14pm    
Not clear. Post the code you are having problems with
safi rehman 4-Oct-14 13:20pm    
I haven't started yet code part. I have a doctor as a user
Appointment is
create table Appointment
(
AppointmentID int identity primary key,
DoctorID int foreign key references Doctors(DoctorID),
PatientID int foreign key references Patients(PatientID),
AppointmentDate date,
StartTime time,
EndTime time
)
how would i add or subtract time to check that appointment slot is available or not?
CHill60 4-Oct-14 13:47pm    
Why would you want to add or subtract time? Present timeslots that are not used or check to see if a particular time is already "booked". You're going to need a darn site more than just that table - if that's all you've got then you are some way away from worrying about details like checking for availability

In .NET Framework you work with DataTime objects when you're creating such schedules and you have many options where you get to add seconds, minutes or even years and similarly you can subtract them from each other and so on.

I have written an article that explains this, and you can learn it there. Understanding DateTime struct in .NET Framework (using C#)[^]

Somehow, I do want to post the very basic code here, to make you understand it without having to go through that entire article (but do give it a read, it will explain the basics about DateTime object in the .NET Framework).

C#
// create a new instance
DateTime dateTime = DateTime.Now;
// add one day to it
dateTime = dateTime.AddDays(1);
// you'll have the same time, but the day would increment by one. 


Same thing goes for subtract, you just pass a negative value to it.
 
Share this answer
 
Comments
[no name] 4-Oct-14 17:42pm    
My 5 for you.
Afzaal Ahmad Zeeshan 4-Oct-14 17:44pm    
Thank you, Bruno!
safi rehman 6-Oct-14 14:58pm    
Thank you Mr Afzaal very helpful :)
You ask for help? Are you willing to pay?

No this Forum as I understand is to help if somebody has a Problem and not to make the work for you.

Sorry for my "English", I'm not native
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900