473,382 Members | 1,581 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,382 software developers and data experts.

How to initial the datetime value to "01/01/2005 00:00:00"?

ABC
How to initial the datetime variable as value to "01/01/2005 00:00:00"?
Dec 19 '05 #1
5 1967
You can do this manually like below in JS..
Of course you can do the same thing in cSharp DateTime class.

var now=new Date();
var wanted=format(now);
function format(now)
{
return
now.getDay()+"/"+now.getMonth()+"/"+now.getFullYear(); // you can add
now.getHours or getMinutes...
}

Dec 19 '05 #2
"ABC" <ab*@abc.com> wrote in news:es**************@TK2MSFTNGP15.phx.gbl:
How to initial the datetime variable as value to "01/01/2005 00:00:00"?


You can use the constructor that allows you to specify each of the values:

[C#]
public DateTime(
int year,
int month,
int day,
int hour,
int minute,
int second
);

so you would say:

DateTime dt = new DateTime(2005, 1, 1, 0, 0, 0);

-mdb
Dec 19 '05 #3
DateTime.Parse("01/01/2005 00:00:00")

ABC wrote:
How to initial the datetime variable as value to "01/01/2005 00:00:00"?


Dec 19 '05 #4
Brian Gideon <br*********@yahoo.com> wrote:
DateTime.Parse("01/01/2005 00:00:00")


I'd advise against this solution. It's very inefficient to use string
parsing when you can specify the parts explicitly with a constructor.
The above might also fail in some cultures (although I don't know of
any where it would fail offhand).

I'd suggest using:

DateTime dt = new DateTime (2005, 1, 1);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 20 '05 #5
Yep. I don't disagree with that suggestion, but since it was already
mentioned I thought I'd provide an alternate method that might be
helpful if the date was stored as a string which I thought, based on
the subject, was the intent of the OP :)

Brian

Jon wrote:
Brian Gideon <br*********@yahoo.com> wrote:
DateTime.Parse("01/01/2005 00:00:00")


I'd advise against this solution. It's very inefficient to use string
parsing when you can specify the parts explicitly with a constructor.
The above might also fail in some cultures (although I don't know of
any where it would fail offhand).

I'd suggest using:

DateTime dt = new DateTime (2005, 1, 1);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Dec 20 '05 #6

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

Similar topics

1
by: Francesc Guim Bernat | last post by:
Dear colleagues, i'm getting in troubles using one XML library with Visual Studio .NET and Xerces with Xalan. When i execute the code i get the next run time error: "Run-Time Check Failure #2...
24
by: jrefactors | last post by:
I have an upload file operation in the web application. UploadForm.jsp is the form, and UploadAction.jsp is the form processing. The web server is Websphere. //UploadForm.jsp <FORM...
0
by: Klemens | last post by:
what do entry's like this in db2diag.log indicate? ------------------------------------------- 2004-01-14-09.07.52.650000 Instance:WWS Node:000 PID:3512(db2syscs.exe) TID:1116 ...
11
by: Robert Lacoste | last post by:
Dear Access gurus, I was using since years Access 97, now under XP SP2, without any problem. However I've just reformatted my HD (viruses...), reinstalled XP SP2, and then I am no longer able to...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
4
by: Muscha | last post by:
Hello, I have a date string in the following format: "2003-10-29T17:44+00:00" When I put it to DateTime.Parse() method it throws an exception, how do I parse this date format? Thanks, /m
7
by: Mathew Butler | last post by:
I'm investigating an issue I have when pulling data back from MS access I'm retrieving all rows from a column in a table of 5000 rows - accessing a column of type "memo" ( can be 65353 character...
3
by: _Christopher\(M2M\) | last post by:
Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) How do I get rid of "Warning C4307: '-' : integral constant overflow" from the following macro? #define...
0
by: tvnaidu | last post by:
database file gets created using below sql file, then lua script calls "db.import config_ascc", then I get errors says "insert table failed for eventLog", below are my sql file entry, config file,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.