I have the name of a day like for example 'Mon'
Is there some function which returns the number of a weekDay if you have the
day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
Thank you,
Simon 11 1543
Hi Simon,
I think I would do it like this.
\\\
Dim myfield As String = "Mon"
Dim mydays As String() = {"Sun", "Mon", "Tue", "rest"}
Dim i As Integer
For i = 0 To mydays.Length - 1
If mydays(i) = myfield Then
MessageBox.Show("I did find " & i.ToString & _
" while the day of week = " & New Date().DayOfWeek)
Exit For
End If
Next
Dim myday As Integer = i + 1
////
I hope this helps?
Cor I have the name of a day like for example 'Mon' Is there some function which returns the number of a weekDay if you have
the day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
"simon" <si*********@stud-moderna.si> schrieb I have the name of a day like for example 'Mon' Is there some function which returns the number of a weekDay if you have the day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
I thought the 7th day is Sunday...
I didn't find a built-in method. The following code should work. I assume
the weekday number is 1 to 7 and the first day of the week is Sunday.
Dim WeekdayNames As String() = { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}
MsgBox(DirectCast(WeekdayNames, IList).IndexOf("Mon"))
If all you need to do with the array is getting the index, you can also
declare it as IList ...
Dim WeekdayNames As IList = New String() { _
Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _
}
.... to avoid type casting each time - or put this huge amount of code in a
procedure or a class.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi Armin,
Nice one (array.indexof) and about that "nothing" I was thinking also, to
start the index on one.
:-)
Cor Dim WeekdayNames As String() = { _ Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _ }
MsgBox(DirectCast(WeekdayNames, IList).IndexOf("Mon"))
If all you need to do with the array is getting the index, you can also declare it as IList ...
Dim WeekdayNames As IList = New String() { _ Nothing, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" _ }
Thank you for your answers.
I have another question:
If I have date="13.12.2003" and hour=9 and second =20 what is the best way
to get datetime value?
datetime=date+hour+second
Thank you,
Simon
"Cor" <no*@non.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl... Hi Simon,
I think I would do it like this. \\\ Dim myfield As String = "Mon" Dim mydays As String() = {"Sun", "Mon", "Tue", "rest"} Dim i As Integer For i = 0 To mydays.Length - 1 If mydays(i) = myfield Then MessageBox.Show("I did find " & i.ToString & _ " while the day of week = " & New Date().DayOfWeek) Exit For End If Next Dim myday As Integer = i + 1 //// I hope this helps?
Cor
I have the name of a day like for example 'Mon' Is there some function which returns the number of a weekDay if you have the day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
Simon, there is a standard Enumeration called "DayOfWeek" which should be
used if possible. In this enumeration, Sunday=0 and Saturday=6. If you want
to use different values, then maybe you should create your own Enumeration
like:
Public Enum MyDaysOfTheWeek
Saturday = 0
Sunday = 1
Monday = 2
etc. etc.
End Enum
You could then use the [Enum].Parse method to turn the String "Monday" into
the value 2. E.g.
myDayOfWeekValue = CType([Enum].Parse(GetType(DaysOfWeek), "Monday"),
DayOfWeek)
I don't recommend using your own enumeration because it will be incompatible
with the DateTime.DayOfWeek() function (which returns what day of the week
the date variable is) If I have date="13.12.2003" and hour=9 and second =20 what is the best way to get datetime value?
To turn that date into a proper date time variable, use the following:
Dim myDate as New Date(2003, 12, 13, 9, 0, 20)
The date structure can take many different arguments as its constructor. In
the example above they are Year, Month, Day, Hour, Minute, Second.
Incedentally, the following will return Saturday (which is equal to 6)
Dim myDate as New Date(2003, 12, 13, 9, 0, 20)
debug.WriteLine(myDate.DayOfWeek)
debug.WriteLine(cint(myDate.DayOfWeek))
Hope this helps,
Trev.
"simon" <si*********@stud-moderna.si> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl... Thank you for your answers. I have another question:
If I have date="13.12.2003" and hour=9 and second =20 what is the best way to get datetime value?
datetime=date+hour+second
Thank you, Simon
"Cor" <no*@non.com> wrote in message news:uf**************@TK2MSFTNGP11.phx.gbl... Hi Simon,
I think I would do it like this. \\\ Dim myfield As String = "Mon" Dim mydays As String() = {"Sun", "Mon", "Tue", "rest"} Dim i As Integer For i = 0 To mydays.Length - 1 If mydays(i) = myfield Then MessageBox.Show("I did find " & i.ToString & _ " while the day of week = " & New Date().DayOfWeek) Exit For End If Next Dim myday As Integer = i + 1 //// I hope this helps?
Cor
I have the name of a day like for example 'Mon' Is there some function which returns the number of a weekDay if you
have the day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
Hi Simon,
I know no best ways, do you mean this?
Dim mydatetime As New DateTime(2003, 12, 13, 9, 1, 20)
I added the hour as one.
Cor If I have date="13.12.2003" and hour=9 and second =20 what is the best way to get datetime value?
datetime=date+hour+second
On Mon, 8 Dec 2003 11:55:56 +0100, Armin Zingler wrote: "simon" <si*********@stud-moderna.si> schrieb I have the name of a day like for example 'Mon' Is there some function which returns the number of a weekDay if you have the day name or I should write the select case statements?
If the day is 'Mon' then result should be 2.
I thought the 7th day is Sunday...
I didn't find a built-in method. The following code should work. I assume
How about this:
Imports System.Globalization
Dim d As New DateTimeFormatInfo
MsgBox((Array.IndexOf(d.DayNames, "Monday") + 1).ToString)
MsgBox((Array.IndexOf(d.AbbreviatedDayNames, "Mon") + 1).ToString)
--
Chris
To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Hi Chris,
Even better for this problem I think.
But I found that filling of the table so nice that Armin was using and than
direct a indexof.
Cor Imports System.Globalization
Dim d As New DateTimeFormatInfo
MsgBox((Array.IndexOf(d.DayNames, "Monday") + 1).ToString) MsgBox((Array.IndexOf(d.AbbreviatedDayNames, "Mon") + 1).ToString)
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> schrieb MsgBox((Array.IndexOf(d.AbbreviatedDayNames, "Mon") + 1).ToString)
Aaaah! "AbbreviatedDayNames" - that's what I didn't find (when doing a
symbol search for "weekday"). :-)
--
Armin
"simon" <si*********@stud-moderna.si> schrieb Thank you for your answers. I have another question:
If I have date="13.12.2003" and hour=9 and second =20 what is the best way to get datetime value?
datetime=date+hour+second
If you have no single variables to "connect" (like shown in the other
answers), you can also use date literals:
dim d as date
d = #12/13/2003 9:0:20#
That's what you type in. It gets converted to
d = #12/13/2003 9:00:20 AM#
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Just remember to be careful of the American format dates though
(#mm/dd/yyyy# instead of #dd/mm/yyyy#).
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uR****************@TK2MSFTNGP11.phx.gbl... "simon" <si*********@stud-moderna.si> schrieb Thank you for your answers. I have another question:
If I have date="13.12.2003" and hour=9 and second =20 what is the best way to get datetime value?
datetime=date+hour+second
If you have no single variables to "connect" (like shown in the other answers), you can also use date literals:
dim d as date d = #12/13/2003 9:0:20#
That's what you type in. It gets converted to d = #12/13/2003 9:00:20 AM#
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: androtech |
last post by:
Hello,
I'm looking for a function that returns a date range for a specified week
number of the year.
I'm not able to find functions like this anywhere. Any pointers/help would
be much...
|
by: peashoe |
last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an
exact date format in the text field (txtDDate). My problem is I need
some javascript that sets an alert that does not allow them...
|
by: Dr John Stockton |
last post by:
It has appeared that ancient sources give a method for Numeric Date
Validation that involves numerous tests to determine month length;
versions are often posted by incomers here. That sort of code...
|
by: Liz Malcolm |
last post by:
Hello and TIA. I have a DE form with an option group that if daily is
selected todays date is used for start and end date, if weekly is
selected Monday - Friday is used. I am trying to add a...
|
by: John Morgan |
last post by:
Does anyone know what parameter should be used instead of Date = 0 for the
optional parameter in the following function?
Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date...
|
by: Assimalyst |
last post by:
Hi,
I have a working script that converts a dd/mm/yyyy text box date entry
to yyyy/mm/dd and compares it to the current date, giving an error
through an asp.net custom validator, it is as...
|
by: Luvin lunch |
last post by:
Hi,
I'm new to access and am very wary of dates as I have limited
experience in their manipulation and I know if they're not done
properly things can turn ugly quickly.
I would like to use a...
|
by: dave |
last post by:
I need to compute an expiration date based on the number of hours,
days, or months purchased.
The expiration date needs to be expressed in minutes something like
'1260481600'.
How can I get the...
|
by: Jes |
last post by:
Dear all
I have a date field on a HTML form where the user is asked to key in
dd/mm/yyyy
However, when that is written to MySql it is either not accepted or
another value is tored in the...
|
by: murch.alexander |
last post by:
I made a simple public function to set and return a date value (see
below). I have a number of queries that call up the function to get
the "As Of Date," which is typically set to today's date....
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
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,...
|
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...
|
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,...
| |