473,414 Members | 1,697 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,414 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 1786
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.