473,388 Members | 1,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Declaring a variable that is a datetime datatype

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

mytoday = DateTime.Now;

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

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 1518

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

mytoday = DateTime.Now;

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

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.ToString();
hth :)

Mythran

Nov 17 '05 #2

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

mytoday = DateTime.Now;

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

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
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...
2
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...
5
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,...
11
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...
5
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...
3
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...
11
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...
2
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.