473,545 Members | 721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declaring a variable that is a datetime datatype

I'm trying to initialize a variable inside a PageLoad in
visualstudio.ne t :

mytoday = DateTime.Now;

...and the error (or Build Task error) says : The name 'mytoday' does
not exist in the class or namespace 'myProject.myfi lename'

when i try :
datetime mytoday = DateTime.Now;
I get an error : the type or namespace datetime cant be found

when doing:
string mytoday = DateTime.Now;
or:
int mytoday = DateTime.Now;
I get an error : cannot be implicitly convert System.DateTime to
string

????
..Net Sports

Nov 17 '05 #1
2 1523

".Net Sports" <ba********@cox .net> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I'm trying to initialize a variable inside a PageLoad in
visualstudio.ne t :

mytoday = DateTime.Now;

..and the error (or Build Task error) says : The name 'mytoday' does
not exist in the class or namespace 'myProject.myfi lename'

when i try :
datetime mytoday = DateTime.Now;
I get an error : the type or namespace datetime cant be found

when doing:
string mytoday = DateTime.Now;
or:
int mytoday = DateTime.Now;
I get an error : cannot be implicitly convert System.DateTime to
string

????
.Net Sports


Try:

DateTime myToday = DateTime.Now;
- or -
string myToday = DateTime.Now.To String();
hth :)

Mythran

Nov 17 '05 #2

".Net Sports" <ba********@cox .net> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I'm trying to initialize a variable inside a PageLoad in
visualstudio.ne t :

mytoday = DateTime.Now;

..and the error (or Build Task error) says : The name 'mytoday' does
not exist in the class or namespace 'myProject.myfi lename'

when i try :
datetime mytoday = DateTime.Now;
I get an error : the type or namespace datetime cant be found

when doing:
string mytoday = DateTime.Now;
or:
int mytoday = DateTime.Now;
I get an error : cannot be implicitly convert System.DateTime to
string

????
.Net Sports

Seriously!

I'm not trying to be a complete bitch here, but you do need to hear this:

If your code above is problematic for you then you are not ready to code in
..NET. And especially not in C#.
You need to get some basic skills in OO and .NET. I would start with some
books and find tutorials on the web.

Oh, C# is case-sensitive. Did you miss that fundamental part of the
language?

Then again, I don't want to be too cynic. Keep on mastering C#. Coding adds
an extra dimension to your life. =)

Happy Learning
- Michael S


Nov 17 '05 #3

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

Similar topics

3
3342
by: r rk | last post by:
I am trying to write a utility/query to get a report from a table. Below is the some values in the table: table name: dba_daily_resource_usage_v1 conn|loginame|dbname|cum_cpu|cum_io|cum_mem|last_batch ------------------------------------------------------------ 80 |farmds_w|Farm_R|4311 |88 |5305 |11/15/2004 11:30 80 ...
2
14211
by: andrew lowe | last post by:
Hi, Please bear with me on this problem, first I'll give you some background: I have an object that contains a DateTime field which i pass to a webservice public class Foo { public DateTime RequestDate; }
5
5874
by: Naveen Mukkelli | last post by:
Hi, I'm writing a server applicaiton using C# and .NET Framework. This server sends out time to all the clients. The clients are expected to be written in various platforms for example, Delphi, VB 6.0, C/C++, Java etc. How I can send the DateTime from .NET Framework to all these other platforms. I heard that sending time in "double"...
11
16406
by: Mark Rae | last post by:
Hi, I have a class with several properties, one of which is of the DateTime datatype. However, this property will not always have a value, and I need to check later whether it has a value or not. When I create a new instance of the class, this property acquires a default value of {1/1/1}, which I don't want at all, as that is a perfectly...
5
11896
by: AirWalker | last post by:
how do I decalre a variable as a datetime datatype in c# for example a variable called 'x' i've tried private DateTime x, and i've tried system.datetime x but none seem to work does anyone have the solution
3
14770
by: Larry Bertolini | last post by:
For some reason, I recall having read that SQL Server 2005 would support a datatype that represented date, but not time. (This would be useful for storing things like birthday, where you usually don't care about the time of day). But I've got SQL Server 2005 installed, and there's no such datatype to be found. Is this something that might...
11
21860
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on another datetime column in the table. See sample below. How do I do this? Any help would be greatly appreciated. Thanks Private Sub...
2
2981
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have this global variable Private dateTime orderDetail= new dateTime(); I want to initialize this variable. How can I do that. Thanks.
3
2691
by: Anil Gupte | last post by:
I am using the followig code: SqlConnection con = new SqlConnection(strcon); con.Open(); string strSelect = "Select PaidUntil from Users where username='" + un + "'"; SqlCommand cmd = new SqlCommand(strSelect, con); SqlDataReader dr; dr = cmd.ExecuteReader(); dr.Read();
0
7465
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
7656
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
7805
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
7416
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
5969
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...
0
4944
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...
0
3449
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...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
701
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...

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.