Visual Basic 6 (VB6)
Visual Basic 6 (VB6)
Username: *
Password: *
The following functions isolate the date portion and time portion, respectively, of
a Date/Time value:
Function Description
DateValue Returns the date portion of a Date/Time value, with the time
portion "zeroed out". (Note: When the time portion of a date/time
variable is "zeroed out", the time would be interpreted as 12:00
AM.)
Example:
dtmTest = DateValue(Now)
TimeValue Returns the time portion of a Date/Time value, with the date
portion "zeroed out". (Note: When a date/time variable is "zeroed
out", the date will actually be interpreted as December 30, 1899.)
Example:
dtmTest = TimeValue(Now)
Function Description
Weekday Returns a number from 1 to 7 indicating the day of the week for a
given date, where 1 is Sunday and 7 is Saturday.
Example:
Note:
Constant Value
vbSunday 1
vbMonday 2
vbTuesday 3
vbWednesday 4
vbThursday 5
vbFriday 6
vbSaturday 7
Function Description
WeekdayName Returns a string containing the weekday name ("Sunday" thru
"Saturday"), given a numeric argument with the value 1 through
7.
Example:
Example:
Example:
Example:
Example:
Example:
You can nest the Month function within the MonthName function
to get the month name for a given date:
Example:
Example:
Year Returns a number from 100 to 9999 indicating the year portion
of a given date.
Example:
Function Description
Hour Returns an integer specifying a whole number between 0 and 23
representing the hour of the day.
Example:
Example:
Example:
To demonstrate the date functions shown thus far, set up a "Try It" project, and
place the following code in the cmdTryIt_Click event:
End Sub
Run the project and click the "Try It" button. The output should look similar to the
following:
Download the VB project code for the example above here.
The generic DatePart function returns an Integer containing the specified part of
a given date/time value. Thus, it incorporates the functionality of the Weekday,
Month, Day, Year, Hour, Minute, and Second functions. In addition, it can used to
get the quarter of a given date (1 through 4) , the "Julian" date (the day of the
year from 1 to 366), and the week number (1 through 53).
Syntax:
DatePart(interval, date[,firstdayofweek[,
firstweekofyear]])
Part Description
interval Required. String expression that is the interval of time you want
to return.
firstdayofweek Optional. A constant that specifies the first day of the week. If
not specified, Sunday is assumed.
firstweekofyear Optional. A constant that specifies the first week of the year. If
not specified, the first week is assumed to be the week in which
January 1 occurs.
To demonstrate DatePart, set up a "Try It" project, and place the following code in
the cmdTryIt_Click event:
Spc(1); _
End Sub
Run the project and click the "Try It" button. The output should look similar to the
following:
The DateSerial takes three numeric arguments: year, month, and day
respectively. It returns a date based on those values.
Example:
intYear = 2001
intMonth = 9
intDay = 2
The TimeSerial takes three numeric arguments: hour, minute, and second
respectively. It returns a time based on those values.
Example:
intHour = 11
intMinute = 34
intSecond = 44
• Printer Friendly
• 91048 reads
Comments
Sat, 07/11/2009 - 15:20 — Need Solutions
Hello Frnds ,
Thanks a lot ... i have learned a lot from this page ....
i mean if my tool runs for 30 seconds .. at the end it should display 30 sec ... if it runs for
2 mins it should display 2 mins ....
i guess .. i am clear enough.
please have a look into it and reply me back..it is very urgent for my project.
Thanks in advance.
• reply
any updates??
• reply
I wrote a cafee clock program to cover my system screen that, if someone want to browse
my system he/she will collect ticket from me and when the time fineshes the program
will block the screen again, the problem now IS HOW (code) TO DISABLE THE
WINDOW KEY BUTTON ON KEYBOARD, THE Ctrl+Alt+Delete and SOME OTHER
SPECIAL KEYS ON KEYBOARD SO THAT WHEN THE FORM LOAD THOSE
KEYS WILL NOT FUNCTION TILL THE USER LOGIN PROPERLY, SO THAT
WHEN THE FORM UNLOADS, IT WILL FUNCTION AGAIN. to prevent an
unauthorize person to login through pressing of window key button or Ctrl+Alt+Delete to
terminate.
Obiekezie
• reply
• reply
for example
• reply
• reply
I wrote a cafee clock program to cover my system screen that, if someone want to browse
my system he/she will collect ticket from me and when the time fineshes the program
will block the screen again, the problem now IS HOW (code) TO DISABLE THE
WINDOW KEY BUTTON ON KEYBOARD, THE Ctrl+Alt+Delete and SOME OTHER
SPECIAL KEYS ON KEYBOARD SO THAT WHEN THE FORM LOAD THOSE
KEYS WILL NOT FUNCTION TILL THE USER LOGIN PROPERLY, SO THAT
WHEN THE FORM UNLOADS, IT WILL FUNCTION AGAIN. to prevent an
unauthorize person to login through pressing of window key button or Ctrl+Alt+Delete to
terminate.
• reply
Hey guys,
I'm trying to set an integer/date to the last Sunday at midnight that went by. So no matter
when in the week the program is run it will find the variable will be set to the last Sunday
@ 00:00 that went by.
• reply
• reply
Help
example:
current date:4/21/2008
number: 3
End Date: 4/24/2008
THxxx
• reply
question to print
• reply
• reply
Option 1 for VB 6
Option 2 for VB 6
Thanks.
• reply
• reply
Good Luck
• reply
i am getting the error "Compile error: Sub or function not defined" in this code. I checked
the references needed for this code. Every references are checked. But still it's showing
the same error. It's showing the error in the monthname area. Can someone help me to get
rid of this problem. The code is given below.
• reply
date
HAI
• reply
I'm not sure how to schedule the program to start at the scheduled time and day from
within the coding.
With thanks for any help you may be able to give me to get started.
Trevor
• reply
Wed, 02/25/2009 - 20:34 — Anonymous (not verified)
• reply
• reply
date/time picker
how will i compute age when i use the date/time picker? thanks....
• reply
Please tell me how to store servers date in oracle database using visual basic 6.0 code.
• reply
Hi,
I am trying to populate an access database table named DateList that will be used to
populate dropdown lists. I want to write code that, from a web page form, will take a
"from" date and a "through" date and populate the table's (only) field Date with dates
between and including from and through.
I only want the date of MONDAY of each week between the two dates.
This is for an online task management tool that I am creating for my department at work.
The reason I need to code this is that other depts will use this as well and each year we
want to clear and repopulate the dates and I have written the code to clear the table but
now need to repopulate it.l
One of my main concerns here is how to determine how to count the days so that I get
Monday's date and increment so that
I do not get say May 35th. Is there a function that keeps track of the actual date so that
once I determine the first Monday in the range I can use something like Date() + 7?
Thanks
W.
• reply
question
• reply
try this:
sql = "SELECT vData1, vData2, dDate FROM table WHERE Day(dDate) = " &
Day(TDBDate.Value) & " AND Month(dDate) = " & Month(TDBDate.Value) & " AND
Year(dDate) = " & Year(TDBDate.Value) Order By dDate"
rs.CursorLocation = 3
rs.LockType = 1
rs.CacheSize = 1
rs.CursorType = 3
rs.Open sql, ConexionString, , , 1
-------------------
DataCombo1.Text = rs("vData1").Value
TextBox1.Text = rs("vData2").Value
ConexionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=USERDB;Initial Catalog=DataBase;Data Source=Server;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=PC;Use Encryption
for Data=False;Tag with column collat"
• reply
Thanks very much for this page and helped and saved lot of time of me in finding some
solutions
• reply
biometric code in vb
good day please help me how to do a system payroll when the in and out of employee is
come in biometric what code can i put???????????????........................the name of
biometric i use is ACROPRINT TIME qPLUS BIOMETRIC >>>
THANKS>>>>>>>>>>>>>>>>>>
• reply
• reply
thank you...
thank you....
• reply
I can't see the answer please post it the exact answer for example I want to add 1 hr. in
current time how can i do that
• reply
dim currenttime as
• reply
• reply
http://www.vb6.us/tutorials/date-time-functions-visual-basic
• reply
• Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl>
<dt> <dd>
• Lines and paragraphs break automatically.
• You may post block code using <blockcode [type="language"]>...</blockcode>
tags. You may also post inline code using <code [type="language"]>...</code>
tags.