473,769 Members | 5,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date from Double

Hello,
In SQL, if I do
Select cast (37797.81597222 22 as datetime)as DateFromDecimal
i get 2003-06-27 19:34:59.997 as the return.

in VB.NET if I do:
Dim idate As Date
idate = Date.FromOADate (37797.81597222 22)
I get 6/25/2003 7:35:00 PM as the return.
Any idea as to why I'm getting different day of the month?

Any idea how I can get vb.net to return the time in the same precision
as SQL? VB.net appears to be rounding the time up to 7:35:00 PM

Thanks!

Oct 27 '06 #1
2 7757
1. An SQL DateTime is not an Automation date (the difference is 2 days),
so to correct for this, add 2 to the double value in VB before
converting it.

2. An SQL DateTime has a precision in milliseconds, VB in seconds, so,
the rounding you mention is correct.


a VB datetime is stored completely differently than SQL DateTimes, so,
stored as a double
ru********@gmai l.com wrote:
Hello,
In SQL, if I do
Select cast (37797.81597222 22 as datetime)as DateFromDecimal
i get 2003-06-27 19:34:59.997 as the return.

in VB.NET if I do:
Dim idate As Date
idate = Date.FromOADate (37797.81597222 22)
I get 6/25/2003 7:35:00 PM as the return.
Any idea as to why I'm getting different day of the month?

Any idea how I can get vb.net to return the time in the same precision
as SQL? VB.net appears to be rounding the time up to 7:35:00 PM

Thanks!
Oct 27 '06 #2
Theo,
Thank you very much for the reply.

Theo Verweij wrote:
1. An SQL DateTime is not an Automation date (the difference is 2 days),
so to correct for this, add 2 to the double value in VB before
converting it.

2. An SQL DateTime has a precision in milliseconds, VB in seconds, so,
the rounding you mention is correct.


a VB datetime is stored completely differently than SQL DateTimes, so,
stored as a double
ru********@gmai l.com wrote:
Hello,
In SQL, if I do
Select cast (37797.81597222 22 as datetime)as DateFromDecimal
i get 2003-06-27 19:34:59.997 as the return.

in VB.NET if I do:
Dim idate As Date
idate = Date.FromOADate (37797.81597222 22)
I get 6/25/2003 7:35:00 PM as the return.
Any idea as to why I'm getting different day of the month?

Any idea how I can get vb.net to return the time in the same precision
as SQL? VB.net appears to be rounding the time up to 7:35:00 PM

Thanks!
Oct 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2391
by: MLH | last post by:
In an Access 97 form, I have a textbox control with the following code that runs AfterUpdate... Option Compare Database Option Explicit Private Sub UNIXdate_AfterUpdate() Me!RealDate = DateAdd("s", , #1/1/1970#) End Sub
5
28323
by: Bryan Yeo | last post by:
Trying to get the user password expire date from AD, but there is no such field. What I could get is the PasswordLastChanged property. Is there anyway I could calculate the date or something? Regards, Bryan
1
4546
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z = Math.Floor(JD+0.5); double W = Math.Floor((Z - 1867216.25)/36524.25); double X = Math.Floor(W/4);
1
15293
by: Kenny | last post by:
I am having issues with the "Date.ToOADate" method in VB .NET. I understand that in VB6 the function DateSerial gives an internal representation of the date. When I use the DateSerial method in VB .Net, dragging the mouse over to the statement, VB .NET reports the following "Conversion from 'Date' to "Double' requires calling the 'Date.ToOAdate' method. When I tyoe this method in, the syntax checker undelines
4
11495
by: sam | last post by:
Possible convert VB 6 to VB.Net 1.1 for date serial function? Example, Calendar_Date = DateSerial(1900+(Julian_Date/1000), 1,Julian_Date Mod 1000) ? Calendar_Date and Julian_Date are input variable. Please advise.
2
1408
by: Brad | last post by:
get the following error when I try to save a date: When converting a string to DateTime, parse the string to take the date before putting each variable in the DateTime object. I was using a calendar control thinking that might have been the problem so I am using just a text box for entry. In the ASP code for the Insert statement, I have this: <asp:controlParameter Name="InDate" Type="DateTime" ControlID="txtInDate" />
4
5313
by: Peter | last post by:
What is the easiest way to convert serialdate (like excel has) into real date in VB.NET? Thank You Peter
5
2407
by: Donkey | last post by:
Hello, I want to find out how many digits does each date type have and how many bytes does it occupy in memory, so I wrote a program below: #include <stdio.h> const long double num=1123222.232121342; main() { Printf("the number occupies: %i, and it is 1123222.232121342 \n",sizeof num); printf("char: %i ,the number is %c\n",sizeof(char),(char)num);
6
14452
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9849
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8861
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7393
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.