473,581 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What happened to the Date() function?

Hi Gang,
VB6 has a command called Date and it would not to surprisingly return the
date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

What is the equivalent of this command in VB.Net?

Thanks in Advance,
Christian Blackburn


Nov 20 '05 #1
7 13958
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
VB6 has a command called Date and it would not to surprisingly return
the date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000
This code does not work in my version of VB6. Is this really VB6 code? Date
is only a property of the VBA.DateTime module. You can also set the date
using

Date = #8/12/2000#

but the syntax

Date(now) = ...

is not valid.
What is the equivalent of this command in VB.Net?

--
Armin

Nov 20 '05 #2
Hello,

"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb:
VB6 has a command called Date and it would not to
surprisingly return the date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

What is the equivalent of this command in VB.Net?


I am not sure which VB Classic function you are referring to. There is no
parameterized 'Date' function in VB Classic. Do you refer to 'DateValue'?

Maybe you want to instantiate 'DateTime' from a string containing the date
information. You can use 'DateTime.Parse ' for this purpose.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3
Hi Guys,
Thanks again for the help I would up going with the following syntax:
strFile_Date = DateTime.Today & " at " & DateTime.Now.Ho ur & ":" &
DateTime.Now.Mi nute

Cheers,
Christian

"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> wrote in message
news:ei******** ********@TK2MSF TNGP09.phx.gbl. ..
Hello,

"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb:
VB6 has a command called Date and it would not to
surprisingly return the date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

What is the equivalent of this command in VB.Net?


I am not sure which VB Classic function you are referring to. There is no
parameterized 'Date' function in VB Classic. Do you refer to 'DateValue'?

Maybe you want to instantiate 'DateTime' from a string containing the date
information. You can use 'DateTime.Parse ' for this purpose.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #4
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> wrote in
news:uU******** ******@tk2msftn gp13.phx.gbl:
Thanks again for the help I would up going with the following syntax:
strFile_Date = DateTime.Today & " at " & DateTime.Now.Ho ur & ":" &
DateTime.Now.Mi nute


Just for your information, you can shorten that to the following:

strFile_Date = Date.Now.ToStri ng("MM/dd/yyyy a\t h:mm tt")
Nov 20 '05 #5
Hi Chris,
Thanks for helping. Your answer is by far the most complete and useful so
far. While I have already created some working code I'm a little curious
what the last tt stands for in: strFile_Date = Date.Now.ToStri ng("MM/dd/yyyy
a\t h:mm tt")?
Thanks in Advance,
Christian Blackburn

"Chris Dunaway" <du******@lunch meatsbcglobal.n et> wrote in message
news:Xn******** *************** ***********@207 .46.248.16...
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> wrote in
news:uU******** ******@tk2msftn gp13.phx.gbl:
Thanks again for the help I would up going with the following syntax:
strFile_Date = DateTime.Today & " at " & DateTime.Now.Ho ur & ":" &
DateTime.Now.Mi nute


Just for your information, you can shorten that to the following:

strFile_Date = Date.Now.ToStri ng("MM/dd/yyyy a\t h:mm tt")

Nov 20 '05 #6
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> wrote in
news:eX******** ******@TK2MSFTN GP09.phx.gbl:
Date.Now.ToStri ng("MM/dd/yyyy a\t h:mm tt")?


It puts the A or P for AM or PM on the end. Look at the docs of the
DateTimeFormatI nfo class for what the characters mean.

Chris
Nov 20 '05 #7
"Christian Blackburn" <Christian@Damn @Sp**@Hotmail.c om> schrieb
Hi Chris,
Thanks for helping. Your answer is by far the most complete and
useful so far. While I have already created some working code I'm a
little curious what the last tt stands for in: strFile_Date =
Date.Now.ToStri ng("MM/dd/yyyy a\t h:mm tt")?


In the docs for the ToString method there's a link to "Date and time format
strings".

Visual Studio.NET
.NET Framework
Programming with .NET Framework
Working with basic data types
Formatting types
-> Date and time format strings

(see hints in signature)
--
Armin

- The tree representing the table of contents has been translated from
localized (German) version. Excuse slight deviations.

Nov 20 '05 #8

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

Similar topics

220
18931
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it...
47
9109
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
9
3533
by: rick cameron | last post by:
TimeZone - the only instance you can get is one representing the local time zone DateTime - cannot represent a time before 00:00:00 1 Jan 1 CE What were they thinking? This is a serious question - can anyone come up with a good reason for these incredible design restrictions? Michael Brumm http://michaelbrumm.com has produced a fix for...
11
7607
by: becte | last post by:
What does the standard say about f(x++) ? 1. x is incremented and then the that value is used in function f, i.e. x++; f(x); 2. the value of x (before ++) is send to f and after returning. x is increased, i.e f(x); x++; 3. undefined behavior, it is different for different compilers I encountered the problem when I was porting code (not...
36
2441
by: MLH | last post by:
Does Date = Date + 1 mean Date Statement equals Date Function plus 1? And if the answer is Yes, how much actual time is being added to the date function in this assignment?
8
2053
by: bdobby | last post by:
Hi. I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened... I have a form with an onsubmit event handler: <form id="uploadForm" method="post" action="..." onSubmit="checkDates()"> The event handler does some minor validation, then returns true or
0
1231
by: tshad | last post by:
I am trying to create a proxy and soap from a sample file and it won't create multiple dimensional arrays for some reason. I am getting the same results if "Line" is not a Multidimensional array. Why is "Line" not there? I have the following Class that I compile and put into my Bin directory as: vbc /t:library NewsItem.vb copy...
18
3118
by: ben.carbery | last post by:
Hi, I have just written a simple program to get me started in C that calculates the number of days since your birthdate. One thing that confuses me about the program (even though it works) is how global variables and function returns work... For example, I have a global array "char datestring;" which is defined in the function speakdate....
132
4548
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C community. It would seem that C99 is the most up-to-date Standard, but far more people seem to be working off the C89 Standard. Could someone...
0
7868
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...
0
8149
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. ...
0
8304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
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...
0
8175
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...
0
6553
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...
1
5674
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...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.