472,364 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

How do I convert a date into a serial number

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.
Nov 21 '05 #1
4 15055
Daniel,

You could use VB's DateDiff function to find the number of time intervals
between the 2 dates. The interval can be days, hours, etc.

You could then use the time intervals to drive the progress bar.

Kerry Moorman
"Daniel Kaseman" wrote:
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.

Nov 21 '05 #2
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor
Nov 21 '05 #3
This is what I done:

1) Start a new Windows application
2) Add a timer, a progressbar & a button to the form
3) Declarations:

Dim dtFrom As Date = #2/3/2005# ' Just a date I picked randomly

Dim dtTo As Date = DateTime.Now

Dim intDays As Integer

4) Double-click the button & add the following code:

intDays = Microsoft.VisualBasic.DateDiff(DateInterval.Day, dtFrom, dtTo)

'MessageBox.Show(intDays)

With ProgressBar1

.Minimum = 1

.Maximum = intDays

End With

Timer1.Enabled = True

Timer1.Interval = 200

5) Double-click the timer & add the following code:

If ProgressBar1.Value < intDays Then

ProgressBar1.Value += 1

Else

ProgressBar1.Value = intDays

Timer1.Enabled = False

End If

6) Run the project.

There are 76 days between the two dates at the time of posting

I hope this helped

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #4
Combining TimeSpan Class with Cor's Ticks is a convienent way to convert to
Days, hours, min, sec, etc.

"Cor Ligthert" wrote:
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor

Nov 21 '05 #5

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
79
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
5
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
3
by: Stewart Allen | last post by:
Hi there I'm trying to find part serial numbers between 2 numbers. The user selects a part number from a combo box and then enters a range of serial numbers into 2 text boxes and the resulting...
3
by: jerry.ranch | last post by:
I have a need to convert simple dates (i.e. 02/14/2005) to a number, do some math, and convert back to a date. (in a simple query). The math involves adding or substracting days, and days of the...
6
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...
4
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
17
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.