How to Concate Date + Time

  • Thread starter edisonl via AccessMonster.com
  • Start date
E

edisonl via AccessMonster.com

Hi,

1.QS: Does anyone knows how to concate Date + Time ?

2.Application: Leave- Annual Leave System

3.Scenerio: Apply Half Day (Half Morning/Afternoon)
Morning=08:30 to13:00 Afternoon=13:00 to 17:30

4.Problem:
FromDate_TextBox = Calender.Value
ToDate_TextBox = Calender.Value

if(HalfDayCheckBox_Check)

Choice=InputBox("Prompt to Choose Morning/Afternoon:")
FromDate_TextBox.Format = "General Date"
ToDate_TextBox.Format = "General Date"


if(Choice=Morning)then
FromDate_TextBox = FromDate_TextBox + "08:30"
ToDate_TextBox = ToDate_TextBox + "13:00"

ElseIf(Choice=Afternoon)then
FromDate_TextBox = FromDate_TextBox + "13:00"
ToDate_TextBox = ToDate_TextBox + "17:30"
EndIf

End If

5.Error: Run-Time Error'13'
type mismatch

Edison
 
J

John W. Vinson

Hi,

1.QS: Does anyone knows how to concate Date + Time ?

Yes, just add them. A Date/Time field is a Double Float number, a count of
days since midnight, December 30, 1899; times are fractions of a day, e.g.
..00000000 is midnight, 0.5000000 is noon, 0.750000 is 6:00 pm.
2.Application: Leave- Annual Leave System

3.Scenerio: Apply Half Day (Half Morning/Afternoon)
Morning=08:30 to13:00 Afternoon=13:00 to 17:30

4.Problem:
FromDate_TextBox = Calender.Value
ToDate_TextBox = Calender.Value
if(HalfDayCheckBox_Check)

Choice=InputBox("Prompt to Choose Morning/Afternoon:")
FromDate_TextBox.Format = "General Date"
ToDate_TextBox.Format = "General Date"

The format is irrelevant. It just controls how the number is displayed, not
what's stored.
if(Choice=Morning)then
FromDate_TextBox = FromDate_TextBox + "08:30"
ToDate_TextBox = ToDate_TextBox + "13:00"

Either add #08:30# or #13:00# - # being the Date/Time delimiter - or use

FromDate_TextBox = DateAdd("n", 510, [FromDate_TextBox]
ToDate_TextBox = DateAdd("h", 13, [FromDate_TextBox]

"n" is miNutes, "h" is Hours (and "m" is Months).
ElseIf(Choice=Afternoon)then
FromDate_TextBox = FromDate_TextBox + "13:00"
ToDate_TextBox = ToDate_TextBox + "17:30"
EndIf

Same logic.
 
E

edisonl via AccessMonster.com

Hi John,
Had managed to resolved it using>>

FromDate_Text = Format(FromDate_Text & " 08:15", "General Date")
ToDate_Text = Format(ToDate_Text & " 13:00", "General Date")

Edison
Hi,

1.QS: Does anyone knows how to concate Date + Time ?

Yes, just add them. A Date/Time field is a Double Float number, a count of
days since midnight, December 30, 1899; times are fractions of a day, e.g.
.00000000 is midnight, 0.5000000 is noon, 0.750000 is 6:00 pm.
2.Application: Leave- Annual Leave System
[quoted text clipped - 4 lines]
FromDate_TextBox = Calender.Value
ToDate_TextBox = Calender.Value
if(HalfDayCheckBox_Check)

Choice=InputBox("Prompt to Choose Morning/Afternoon:")
FromDate_TextBox.Format = "General Date"
ToDate_TextBox.Format = "General Date"

The format is irrelevant. It just controls how the number is displayed, not
what's stored.
if(Choice=Morning)then
FromDate_TextBox = FromDate_TextBox + "08:30"
ToDate_TextBox = ToDate_TextBox + "13:00"

Either add #08:30# or #13:00# - # being the Date/Time delimiter - or use

FromDate_TextBox = DateAdd("n", 510, [FromDate_TextBox]
ToDate_TextBox = DateAdd("h", 13, [FromDate_TextBox]

"n" is miNutes, "h" is Hours (and "m" is Months).
ElseIf(Choice=Afternoon)then
FromDate_TextBox = FromDate_TextBox + "13:00"
ToDate_TextBox = ToDate_TextBox + "17:30"
EndIf

Same logic.
End If

5.Error: Run-Time Error'13'
type mismatch

Edison
 
J

John W. Vinson

Hi John,
Had managed to resolved it using>>

FromDate_Text = Format(FromDate_Text & " 08:15", "General Date")
ToDate_Text = Format(ToDate_Text & " 13:00", "General Date")

Edison

<shrug>

Ok, that generates a TEXT STRING not a date/time. It does not do what your
original post asked for. If it's working for you, fine...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top