Problem: conversion of a variable

danbiff

New Member
Licensed User
Longtime User
Hello,

I have got a little problem concerning the conversion of a variable. I get different results if I run the following code on my pc and on my mobile phone:

Dim test As String
Dim test2 As Number

DateFormat("dd.mm.yyyy")
test = DateParse("01.01." & DateY)
Msgbox(test)
test2 = DateParse("01.01." & DateY)
Msgbox(test2)

I get the following messages on my pc:
"633979008000000000"
"6.33979008E+17"

On my phone on the other hand twice I get the message:
"6.33979008E+17"

Is there any way that I also can get the result "633979008000000000"? Or is it just a problem with my mobile phone. I need this information ("01.01." & DateY) for a sql statemtent. I would like to avoid converting "6.33979008E+17" to "633979008000000000".

I have already searched through the forum but I could not find anything. Sorry if this question has been asked and answered in the past.

Thanks in advance for any help.

EDIT:
One line missing in the code at the top --> DateFormat("dd.mm.yyyy")
 
Last edited:

sitajony

Active Member
Licensed User
Hi, on device you can't show more than 9 digits after the dot (Like in JavaScript and other), the better way is to round your number to 9 digits:

test=Round(test,9)

Maybe I'm wrong...

Edit:
Sorry I didn't well see:
You can use the SubString() function and keep only 9 digits...
test=SubString(test,0,9)
 
Last edited:

danbiff

New Member
Licensed User
Longtime User
Thank you for the answer. But unfortunatly i can't round at that point. I need the exact value for the following code:

...
date = DateParse("01.01." & DateY)
Command.SetParameter("date", date)
Command.CommandText = "UPDATE termin SET vereinbart=0, absolviert=0 WHERE (vereinbart=1 OR absolviert=anzahl) AND date<@date"
...

The result is that the sql statement does not update any records. This works on the pc because it has the correct value in @date. This is why I also can't use SubString().
 

agraham

Expert
Licensed User
Longtime User
You will probably find that if you compile it on the desktop you will also get the scientific notation when the ticks are converted to string - which is what is happening when you use MsgBox. To format the string the way you want use

Format(test, "F0")
 

mjcoon

Well-Known Member
Licensed User
"633979008000000000"
"6.33979008E+17"

These are just different representations of the same value (as counting the digits will show.

Using the Format(test, "d1") function should render the value as a strict integer if required. Unfortunately I tried it and it gives a wrong (negative!) answer. Deeper into bug territory?

Mike.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…