I have the following code to get the number of seconds into a day given
a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate)
StillDate is #04/05/2006 21:03:52#, and DateValue is correct at
#04/05/2006# yet TValS is giving me -2429768 (Yes, negative 2.4 million)
This only occurs on 3 machines we've seen so far (none we have direct
access to)
Has anyone ever seen anything like this before or can point to a
particular hardware "feature"?
Thanks
--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team
iCode Systems 7 5746
Dean Earley wrote: I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate)
StillDate is #04/05/2006 21:03:52#, and DateValue is correct at #04/05/2006# yet TValS is giving me -2429768 (Yes, negative 2.4 million)
This only occurs on 3 machines we've seen so far (none we have direct access to) Has anyone ever seen anything like this before or can point to a particular hardware "feature"?
Interestingly, this number is CORRECT for:
?DateDiff("s", #05/04/2006#, #04/05/2006 21:03:52#)
-2429768
Notice the day/month parts being swapped...
MSDN does say it expects a string but can handle "any expression that
can represent a date, a time, or both a date and time" but as StillDate
is typed as a Date, I'd expect this to be unambiguous.
--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team
iCode Systems
On Thu, 06 Apr 2006 10:26:33 +0100, Dean Earley
<de*********@icode.co.uk> wrote: I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate)
Is StillDate a String or a Date ?
It looks as if you are trying to get seconds from midnight
StillDate is #04/05/2006 21:03:52#, and DateValue is correct at #04/05/2006# yet TValS is giving me -2429768 (Yes, negative 2.4 million)
This only occurs on 3 machines we've seen so far (none we have direct access to) Has anyone ever seen anything like this before or can point to a particular hardware "feature"?
Most likely a Locale problem
If StillDate is a Date type then extract its bit after the decimal
point and multiply by 24 * 60 * 60 to get seconds
>>I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate)
Is StillDate a String or a Date ?
And if StillDate is declared as a Date, how is the value being assigned to
it?
Rick
>> I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate) Is StillDate a String or a Date ?
Its a Date variable (its value is correct).
It looks as if you are trying to get seconds from midnight
Exactly. StillDate is #04/05/2006 21:03:52#, and DateValue is correct at #04/05/2006# yet TValS is giving me -2429768 (Yes, negative 2.4 million)
This only occurs on 3 machines we've seen so far (none we have direct access to) Has anyone ever seen anything like this before or can point to a particular hardware "feature"?
Most likely a Locale problem
The locale settings don't appear to affect it in any way.
The failing machines are using the same locale as our test machines and
my devlopment machine.
Nor does timezone and the current date/time.
If StillDate is a Date type then extract its bit after the decimal point and multiply by 24 * 60 * 60 to get seconds
That's ok in this case but it would be nice to know why its going wrong
in case we come across it again.
--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team
iCode Systems
Rick Rothstein wrote: I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate) Is StillDate a String or a Date ?
And if StillDate is declared as a Date, how is the value being assigned to it?
CopyMemory from two longs (Passed cross process).
The data is confirmed the same as the original.
--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team
iCode Systems
"Dean Earley" <de*********@icode.co.uk> wrote in message
news:44*********************@news.zen.co.uk... Rick Rothstein wrote: I have the following code to get the number of seconds into a day given a date/time value:
TValS = DateDiff("s", DateValue(StillDate), StillDate) Is StillDate a String or a Date ?
DateValue takes a string, not a Date. So you have an implicit conversion from
Date to String, prior to the conversion by DateValue back to a Date. It would
seem that the implicit conversion is producing a string in a different date
format on the 3 unhappy machines.
You might first try DateDiff("s", DateValue(CStr(StillDate)), StillDate) to see
if you can make the conversion more consistent, or at least to make clear what
conversions are actually taking place.
My preference would be DateDiff("s", Fix(StillDate), StillDate), leaving strings
out of the deal.
Steve Gerrard wrote: "Dean Earley" <de*********@icode.co.uk> wrote in message news:44*********************@news.zen.co.uk... Rick Rothstein wrote:> I have the following code to get the number of seconds into a day given > a date/time value: > > TValS = DateDiff("s", DateValue(StillDate), StillDate) Is StillDate a String or a Date ? DateValue takes a string, not a Date. So you have an implicit conversion from Date to String, prior to the conversion by DateValue back to a Date. It would seem that the implicit conversion is producing a string in a different date format on the 3 unhappy machines.
We've got a response back from the user saying that their short date
format was "M/dd/yyyy" which would explain this. Changing back to
"dd/mm/yyyy" sorted it.
We originally thought DateValue was returning correct values as his
debug output was showing "5/4/2006" which while looking correct to us,
was in the US format...
You might first try DateDiff("s", DateValue(CStr(StillDate)), StillDate) to see if you can make the conversion more consistent, or at least to make clear what conversions are actually taking place.
My preference would be DateDiff("s", Fix(StillDate), StillDate), leaving strings out of the deal.
I assumed (From MSDN) that it accepted date values so was unambiguous
anyway. I will now try Int() to see how that performs.
Thanks
--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team
iCode Systems This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: News Central |
last post by:
To all!
I use the DateDiff function using VB6 and get this error 'Wrong number of
argument or invalid property assignment' ... have anyone seen this problem?
thanks ....
|
by: CJM |
last post by:
I have an ASP page that lists files and folders in a directory. I'm using a
cookie to record the last time this page was visited, and I intend to show
links that are created/modified from that date...
|
by: Lofty |
last post by:
Hi all.
I have to write an app that interacts with mySQL (I really must have done
some evil, evil stuff in a previous life to be landed with this!)
I need to work out the difference in days...
|
by: Paolo |
last post by:
I am having some problem with a Year Function.
I have form on which I have 4 field which indicate dates and an
additional form which sums those dates:
These are the fields:
YEARS...
|
by: PMBragg |
last post by:
Thank you in advance. I'm trying to pull all inventory items from December
of the previous year back to 4 years for my accountant. I know this can be
done, but I'm drawing a blank. I've tried;
...
|
by: PMBragg |
last post by:
ORINGINAL Post
>Thank you in advance. I'm trying to pull all inventory items from December
>of the previous year back to 4 years for my accountant. I know this can be
>done, but I'm drawing a...
|
by: OdAwG |
last post by:
Hello Again Access GURU's,
Need some help with Conditional Formatting and datediff. What I am trying
to do is the following:
I have three text boxes with dates in them and what I want to do...
|
by: TofuTheGreat |
last post by:
I did a group search and found hundreds of cases of problems with
DateDiff(). I read through several dozen but they didn not apply to
my situation. Not having the time to read through all of them...
|
by: cmdolcet69 |
last post by:
I'm trying to use the DateDiff function to calculate the difference
whether a shift has been setup. when i run the code below with
strFirstShiftEnd as a stringor date or datetime. I get an error...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |