473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Playing with System.DateTime

Hello gurus,
I'm building a small booking system and i have come accross quiet a tedious
pitfall.

"I need to make sure that people do not book for tomorrow when todays time
is greater or equal to 11."
Well some of you probably allready know the answer but this is not so
obvious for me.

Can anyone solve this puzzle for me?

The booking hour is of no importance. Only the hour at which we are making
this booking
and only if it is the day after today.
Many thanks in advance

J.B

Nov 16 '05 #1
2 1781
bredal Jensen <br******@jensen.dk> wrote:
I'm building a small booking system and i have come accross quiet a tedious
pitfall.

"I need to make sure that people do not book for tomorrow when todays time
is greater or equal to 11."

Well some of you probably allready know the answer but this is not so
obvious for me.

Can anyone solve this puzzle for me?

The booking hour is of no importance. Only the hour at which we are making
this booking and only if it is the day after today.


if (DateTime.Now.Hour >= 11 && // If it's later than 11am today
// And the booking is after tomorrow midnight
booking >= DateTime.Today.AddDays(1) &&
// And the booking is earlier than 2 days hence midnight
booking < DateTime.Today.AddDays(2))
{
....
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Great, your code seems to solve my problem.
Ánd i will happily use it.
By the way will the following work?
So far it seems to work. I'just afraid it may break down
for some combination.

if (DateTime.Now.AddHours(13).Day==bookDate.Day) { do not book}

Anyway i have a solution, your solution.

Many thanks...


"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
bredal Jensen <br******@jensen.dk> wrote:
I'm building a small booking system and i have come accross quiet a tedious pitfall.

"I need to make sure that people do not book for tomorrow when todays time is greater or equal to 11."

Well some of you probably allready know the answer but this is not so
obvious for me.

Can anyone solve this puzzle for me?

The booking hour is of no importance. Only the hour at which we are making this booking and only if it is the day after today.


if (DateTime.Now.Hour >= 11 && // If it's later than 11am today
// And the booking is after tomorrow midnight
booking >= DateTime.Today.AddDays(1) &&
// And the booking is earlier than 2 days hence midnight
booking < DateTime.Today.AddDays(2))
{
...
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bredal Jensen | last post by:
Hello gurus, I'm building a small booking system and i have come accross quiet a tedious pitfall. "I need to make sure that people do not book for tomorrow when todays time is greater or...
5
by: Abdolhosein Vakilzadeh Ebrahimi | last post by:
Is there any way to construct a System.DateTime which doesn't check year, month and day to be in correct range== no validation? Thanks A.V.Ebrahimi
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
13
by: bredal Jensen | last post by:
Hello gurus, I'm building a small booking system and i have come accross quiet a tedious pitfall. "I need to make sure that people do not book for tomorrow when todays time is greater or...
3
by: slylos | last post by:
I've got a section of code in my app that keeps track of how much time an employee has accrued, which equals out to 1.33 days of PTO per month. I'm trying to store the time accrued so far in an...
3
by: Hugh G. Johnson | last post by:
Hi, I have just installed a shopping cart system that is build using the asp.net 1.1 frame work and a SQL 2000 db. The production server is a WS03 box running IIS 6, SQL 2000 (sp3), and has...
18
by: Atara | last post by:
In my apllication I use the following code: '-- My Code: Public Shared Function strDate2Date(ByVal strDate As String) As System.DateTime Dim isOk As Boolean = False If (strDate Is Nothing)...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
5
by: Brian | last post by:
Hello all. I have a simple application that I was using to test and understand the System.Timers.Timer and noticed that when I stop the application, on occasion, it throughs the following...
0
by: maolimix | last post by:
Hi to all, I have a trouble with datetime...now I explain.. I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005. I tried 3 methods ...in the first two I never...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.