473,778 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net Date Serial?

sam
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.

Many thanks.
Nov 21 '05 #1
4 11495
sam wrote:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


DateSerial is still supported in VB.NET 1.1. If you can't get it working,
try this:

\\\
Calendar_Date = Microsoft.Visua lBasic.DateSeri al(1900+(Julian _Date/1000),
1,Julian_Date Mod 1000)
///

If that's not working either, what error message do you get?

--

(O) e n o n e
Nov 21 '05 #2
"sam" <sa*******@ajik l.com.my> schrieb:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


VB.NET still supports 'DateSerial'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3
sam
I have an error message during perform dateserial in VB.Net 1.1 based on my
coding as shown as below:

Coding
-------
Imports System
Imports System.Data
Imports Microsoft.Visua lBasic

Dim Inv_Date, GL_Date, InvDte,GLdte As Double

InvDte = CDbl(InvDte)
GLdte = CDbl(GLdte)

ADO Connection.....
Try
Do While dbrRD_F0411B.Re ad
InvDte = CDbl(dbrRD_F041 1B("RPDIVJ"))
GLdte = CDbl(dbrRD_F041 1B("RPDGJ"))

GL_Date = DateSerial(1900 +(GLdte/1000), 1,GLdte Mod 1000)
Inv_Date= DateSerial(1900 +(InvDte/1000),1,InvDte Mod 1000)
Loop
End Try

Error Message
---------------
BC30532 : Conversion from 'Date' to 'Double' requires caling the
'Date.ToOADate' method

Please advise.

Many thanks.
"Oenone" <oe****@nowhere .com> wrote in message
news:dN******** ******@newsfe1-win.ntli.net...
sam wrote:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


DateSerial is still supported in VB.NET 1.1. If you can't get it working,
try this:

\\\
Calendar_Date = Microsoft.Visua lBasic.DateSeri al(1900+(Julian _Date/1000),
1,Julian_Date Mod 1000)
///

If that's not working either, what error message do you get?

--

(O) e n o n e

Nov 21 '05 #4
sam wrote:
I have an error message during perform dateserial in VB.Net 1.1 based
on my coding as shown as below:
[...] Dim Inv_Date, GL_Date, InvDte,GLdte As Double
GL_Date = DateSerial(1900 +(GLdte/1000), 1,GLdte Mod 1000)

[...]

Ah, that's not a problem with DateSerial, that's a problem with variable
typing.

In VB6, dates were stored as Double values so you could directly assign a
Date to a Double variable.

In VB.NET, dates have their own distinct type (Date) and you can't directly
convert between them.

If you want to do what you're doing above, you will need to either:

1. Change your GL_Date (and probably your other variables too) to be defined
As Date instead of As Double. However, this will most likely break your
dbrRD_F0411B calls as they presumably return Double values too. You'll need
to change these to also return Date values.

2. Alternatively, leave your variables as Doubles and use the OLE Automation
Date conversion functions. These two methods are defined against the Date
class are can be used to convert a value from a Date to a Double (the
ToOADate() function) or from a Double to a Date (the FromOADate() function).

\\\
'Convert Date to a Double
GL_Date = DateSerial(2005 ,5,30).ToOADate

'Convert Double back to a Date
Dim d As Date = Date.FromOADate (GL_Date)
///

Hopefully that'll set you off in the right direction.

--

(O) e n o n e
Nov 21 '05 #5

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

Similar topics

1
2832
by: hartley_aaron | last post by:
Hi, I was trying to blank out (null out?) a field of a record that is a date/time data type. Here is code excerpt: Dim D As Database Dim rsRacks As Recordset Dim strSQL As String strSQL = "SELECT Racks.* FROM Racks WHERE (((Racks.)= "
5
1360
by: diablo | last post by:
hi my access database may be placed on OS with different date settings - i.e. the date may be m/d/y or d/m/y how can i use this databse in a consisten way? I want to be able to sort on the date for example 'select * from ... mydatetime asc'
4
15413
by: Daniel Kaseman | last post by:
How do I convert a date into a serial number? (I'm trying to enter a FROM date and a TO date, then make my PROGRESS BAR show how close I am to the TO date.) get it? I know that MS Excel converts Dates into serial numbers, but I can't figure out how to do it with VB.Net. Please help, thanks.
6
1963
by: Trekmp | last post by:
I currently work in ASP and am in the process of moving some application across to PHP. At present I store dates in a database in numerical format 38694, which is 08/12/2005. In ASP its very easy to convert this value back into a date, but I cannot find a way to do this in PHP. Thanks for any help
3
2719
by: Glencannon4424 via AccessMonster.com | last post by:
Hello, I have what I believe amounts to a Date Serial issue. I have the following columns in my table: Hire-Date Hire-Year WTD-RATE Wks-in-Yr
4
5315
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
1
1839
by: Graham Feeley | last post by:
I have a date field named rcdate it is a general date eg: 12/08/2006 3:30:00 PM 12/08/2006 3:00:00 PM I used to update another empty field named rdate with the with using in a update query " Left(Ratings!RCDate,10)" This now does not work for some reason gives me the error "undefined function in left function"
1
1322
by: scolivas | last post by:
Hi all, I have a situation that is requiring me to make an Entry Date part of the Primary Key. Problem I am having is that it includes the time too. What I have is an inventory return table. It consists of 3 fields - Date, Serial #, Model # Currently I have the Serial # & Model # taged as the Primary key - But..... Now I am being told that items might come back more than once...
8
6808
by: trixxnixon | last post by:
i want to use the date from a date field that also has the time stamp and calculate it within an access query. WHERE Day(DateSerial(<d>, <m>, <y>))=<d> would it be possible to only include the date serial dd/mm/yy of the startfield, and leave the time stamp out using the function above in the function below. Somefield: Workingdays(,) would there be any other way to get the desired output?
0
10292
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
10061
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
9923
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
8954
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
7471
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
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.