Hello guys,
Is there anything wrong with my code (see below) bcoz when 10p-6a shift my
browser returns the error cannot be a zero-length string. Im wondering why,
bcoz the 2 other shift works perfectly.
<%
'Shift: 6a-2p
if DatePart("h", Now()) 5 And DatePart("h", Now()) < 14 then
ShiftID = "A"
end if
'Shift: 2p-10p
if DatePart("h", Now()) 13 And DatePart("h", Now()) < 22 then
ShiftID = "B"
end if
'Shift: 10p-6a
if DatePart("h", Now()) 21 And DatePart("h", Now()) < 6 then
ShiftID = "C"
end if
%> 2 2127
le0 wrote:
'Shift: 10p-6a
if DatePart("h", Now()) 21 And DatePart("h", Now()) < 6 then
ShiftID = "C"
end if
When is something greater than 21 AND less than 6? Unlike your other
conditions, you can use OR for this one:
If DatePart("h",No w) 21 OR DatePart("h",No w) < 6 Then
ShiftID = "C"
End If
Of course, this might not be a bad place for a Select Case Statement:
Select Case DatePart("h",No w)
Case 6,7,8,9,10,11,1 2,13 ShiftID = "A"
Case 14,15,16,17,18, 19,20,21 ShiftID = "B"
Case Else ShiftID = "C"
End Select
And if you really want to shorten it, this will handle all three of your
conditions:
Shifts = Array("A","B"," C")
ShiftID = Shifts((DatePar t("h",Now)+18)\ 8 Mod 3)
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Thanks Dave youre d'best =)
"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:12******** *****@corp.supe rnews.com...
le0 wrote:
> 'Shift: 10p-6a if DatePart("h", Now()) 21 And DatePart("h", Now()) < 6 then ShiftID = "C" end if
When is something greater than 21 AND less than 6? Unlike your other
conditions, you can use OR for this one:
If DatePart("h",No w) 21 OR DatePart("h",No w) < 6 Then
ShiftID = "C"
End If
Of course, this might not be a bad place for a Select Case Statement:
Select Case DatePart("h",No w)
Case 6,7,8,9,10,11,1 2,13 ShiftID = "A"
Case 14,15,16,17,18, 19,20,21 ShiftID = "B"
Case Else ShiftID = "C"
End Select
And if you really want to shorten it, this will handle all three of your
conditions:
Shifts = Array("A","B"," C")
ShiftID = Shifts((DatePar t("h",Now)+18)\ 8 Mod 3)
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David |
last post by:
Hi Group,
i am trying to use the DatePart function on my SQL2000 database. I have a
table called visitors with a field called DateTimeEntrance which is filled
everytime a visitor enters the site. I am trying to build a stat page where
i display the total amount of visitors per day, week, month, year and i
can't seem to get the syntax correct.
I get an error with the following code:
sql = "SELECT * FROM tblVisitors WHERE...
|
by: Tipple |
last post by:
I'm trying to increment between the end of lunch and the end of the day. The
code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and
14 instead of 2:00:00 PM etc..
If response.write just counter2 I get a real hour.
How can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
|
by: sdowney717 |
last post by:
The field itemdate is a datetime field in sqlserver2000 DB
This works fine:
Select Id From BookData Where (MONTH(itemdate) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order by
TitleDuplicate
This does not work:
Select Id From BookData Where (MONTH(itemdate) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') and (datepart(Hh,
|
by: david liu |
last post by:
i have a date (in date/time format with input mask) in access 2002.
field date: 01/01/1970
what i want: 010170 (i.e. mmddyy)
i used:
DatePart("m",) + DatePart("d",) +
right(DatePart("yyyy",), 2)
and i get: 1170
|
by: Aaran76 |
last post by:
I am creating a booking system in ASP.Net with VB and a MSSQL backend.
I am having problems knowing where to begin with a particular part of the
system. Bookings can only be made in weekly multiples from Saturday to
Saturday.
The only way I can think of to do it is by manually adding the weeks into a
table in the DB, but this will obviously mean that I will have to routinely
update this table.
| |
by: S. van Beek |
last post by:
Dear reader,
With DatePart() you can subtract the year or the week from a date field
with:
DatePart("yyyy";) for the year
|
by: troddy |
last post by:
I am using the DatePart funtion in a query to extract the day, month
and year in separate fields in a query. The function works fine but I
am only getting a number for the month even if the field type is a long
date and the month is stored in the table. I tried the following to try
and get the name of the month to work.
DateTest: Format(DatePart("m",),"mmmm")
The DateAffirmed field had a date stored of 16/03/2006.
|
by: Mika M |
last post by:
Hi!
I'm converting some methods of VB-class into C#-class for another
project. It's quite easy, but when converting method which returns last
week number of the entered year I got problems. The VB code is...
Private Function GetLastWeek(ByVal year As Integer) As Integer
'// Get last day of the year
Dim dte As DateTime = New DateTime(year, 12, 31)
'// Return last day weeknumber of the year
|
by: grabit |
last post by:
Hi Peoples
I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007
i have 2 drop down boxes to select the listedmonth and listedyear on the refering page
I need to be able to retrieve this so i can send out renewals to those listings for another year.
I am using this query
<cfquery name="getrenew" datasource="#dsn#">
SELECT datelisted
FROM listings
WHERE...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |