|
-
August 27th, 2001, 03:14 PM
#1
Combine Date and Time in one variable
Hi,
I have two Date variables, the first
one contains a Date, and the other one
contains a Time.
I want to combine them into one variable
that will hold the date from the first
variable, and the time from the
second variable.
I managed to do so by converting them to
strings then assigning the resulting string
into the third variable.. as in the
following example:
Dim da1 as date, ti1 as date, cmb as date
da1 = #9/2/2001#
ti1 = #6:30:00 PM#
cmb = da1 & " " & ti1
MsgBox cmb
the problem with that code is that it does
not interpret dates very well... for example
where '9' in da1 is considered december,
it is understood by cmb as day 9 of Feb!
and if I reversed it .. it still give
a wrong meaning..
however when I tested the code in my home
computer.. it works well with the same
values with no problems (both computers
running Windows 2000 Pro)..
I think that there must be a better
way to do it..
if you have any Idea or thought .. please help!
Thanks in advance
-
August 27th, 2001, 03:55 PM
#2
Re: Combine Date and Time in one variable
Why you do not add them, just like:
da3=da1 + ti1.
You'll have correct result in da3 variable. Then display it as you want.
Vlad
-
August 27th, 2001, 06:00 PM
#3
Re: Combine Date and Time in one variable
Hi,
It seems that your two computers are using different system locale.
The system locale can be changed from Control Panel. Double-click the Regional Settings icon, and then change the system locale value (and then restart your computer).
Regards,
Michi
-
August 28th, 2001, 12:23 AM
#4
Re: Combine Date and Time in one variable
Thanks Michi...
both computers have the same locale! and I was looking for a locale-independant method.
the solution was as vchapran said.. just add them!
Thanks for your reply.
-
August 28th, 2001, 12:25 AM
#5
Re: Combine Date and Time in one variable
Thanks vchapran,
You were right.. how could I miss that! I've tried 'da1 & da2' but I didn't think of 'da1 + da2' !
Thanks again and Regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|