You are on page 1of 4

Re : Date and Time on Label

Option 1 for VB 2008

Put this in the form_load event


Label1.Text = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now)
Label2.Text = "Time : " + TimeValue(Now)

Put this in the timer1_tick event


Label1.Text = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now)
Label2.Text = "Time : " + TimeValue(Now)

Option 2 for VB 2008

Put this in the form_load event


Label1.Text = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now) + " "
+ "Time : " + TimeValue(Now)

Put this in the timer1_tick event


Label1.Text = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now) + " "
+ "Time : " + TimeValue(Now)

Option 1 for VB 6

Put this in the form_load event


Label1.Caption = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now)
Label2.Caption = "Time : " + TimeValue(Now)

Put this in the timer1_timer event


Label1.Caption = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now)
Label2.Caption = "Time : " + TimeValue(Now)

Option 2 for VB 6

Put this in the form_load event


Label1.Caption = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now) +
" " + "Time : " + TimeValue(Now)

Put this in the timer1_timer event


Label1.Caption = "Date : " + WeekdayName(Weekday(Now)) + " " + DateValue(Now) +
" " + "Time : " + TimeValue(Now)
Time Calculations

Time Calculation

If you have two text boxes with times in them

Dim d1, d2 as string


Dim hourz, minz, secz as Integer

d1=trim(Text1.text)
d1=trim(Text2.text)

' Find Hour Difference


hourz = DateDiff("h", d1, d2)

' Find Minutes Difference


minz = DateDiff("n", d1, d2)

'Find Seconds Difference


secz = DateDiff("s", d1, d2)

Debug.Print hourz
Debug.Print minz
Debug.Print secz

time difference

hi guys
how to solve the time difference in hours and minutes using sql...?
example given

time_in = 07:30 AM
time_out = 5:02 PM

Time Serial

Dim intHour As Integer

Dim intMinute As Integer

Dim intSecond As Integer

Dim dtmNewTime As Date


intHour = 11

intMinute = 34

intSecond = 44

dtmNewTime = TimeSerial(intHour, intMinute, intSecond)

'returns 11:34:44 (AM)

Function Description
Hour Returns an integer specifying a whole number between 0 and
23 representing the hour of the day.

Example:

intHour = Hour(Now) ' intHour = 21 (for 9 PM)

Minute Returns an integer specifying a whole number between 0 and


59 representing the minute of the hour.

Example:

intMinute = Minute(Now) ' intMinute = 15

Second Returns an integer specifying a whole number between 0 and


59 representing the second of the minute.
Example:

intSecond = Second(Now) ' intSecond = 20

You might also like