|
|
Hello everyone,
I want to get the same time in yesterday, is there any bug in my below code?
My concern is code, _CurrentDate.Now.Day - 1, if current date is 1, 1 minus 1 is zero, not a valid date?
DateTime _CurrentDate = DateTime.Now;
DateTime _LastDate = new DateTime(_CurrentDate.Now.Year, _CurrentDate.Now.Month, _CurrentDate.Now.Day - 1, _CurrentDate.Now.Hour, _CurrentDate.Now.Second);
thanks in advance,
George
|
|
|
|
|
George_George,
You should use:
DateTime.AddDay(-1);
This will take into account if its the 1st day of the month.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thanks Gareth,
A harder question for you, how to check if two DateTime type instance is in the same day?
regards,
George
|
|
|
|
|
George_George,
If (DateTime1.Now.Day == DateTime2.Now.Day)
HaveAParty();
Do you mean the above?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Your code is wrong, Gareth.
Maybe it is my mistake not making myself understood. I want to check whether two DateTime type instance are of the same date, not the same day.
From your code, you can see May 1st and June 1st are the same date.
Any ideas about how to fix it?
DateTime d1 = new DateTime(2008, 5, 1);
DateTime d2 = new DateTime(2008, 6, 1);
if (d1.Day == d2.Day)
{
Console.WriteLine("hit");
}
regards,
George
|
|
|
|
|
George_George,
If you want to check the dates are the same just do:
If (d1.Now == d2.Now)
HaveAParty();
Or am i not understanding you correctly?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Sorry, Gareth!
I have not made myself understood. I want to check whether two time are belonging to the same date, for example, the time of 8am of current day, has the same date of 9am of current day.
But 8am of May first and 8am of June first, even if they have the same Day property, but belonging to different date.
Any ideas to fix it?
regards,
George
|
|
|
|
|
I would subtract one from the other and see if the number of days in the timespan returned >=1 or <= -1
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Seems not working, here is my test case. Any comments?
DateTime d1 = new DateTime(2008, 5, 1, 23, 59, 0);
DateTime d2 = new DateTime(2008, 5, 2, 0, 0, 1);
if ((d2 - d1) > TimeSpan.FromDays(1))
{
Console.WriteLine("hit");
}
regards,
George
|
|
|
|
|
How about
if (DateTime.Compare(d1.Date, d2.Date) == 0)
{
Console.WriteLine("Same Date");
}
ah just noticed answer was already in thread but off bottom of my browser
|
|
|
|
|
Thanks Alex@UEA,
Your solution works! Cool!
regards,
George
|
|
|
|
|
|
Thanks PIEBALDconsult!
It works!
regards,
George
|
|
|
|
|
Im new to Visual C#.
I have a problem using the ImageList Tool.
I added all the images i need for my program in there and i want to make them appear in some PictureBoxes i made in the Form when a button is clicked.
The problem is i have little to no idea how to make that happen, can someone help me?
|
|
|
|
|
decoyoctopus,
What don't you understand?
yourPictureBox.Image = yourImageList[imageToDisplay];
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thats what i wanted
Thanks, that helped a lot
|
|
|
|
|
Hello guys,
I'm developing a mailing application where I want to deliver my mails to a relay SMTP server.
(This is a linux postfix server which is configured for outgoing performance).
So in my app I just use the smtpclient to connect to this server and send the messages.
Now I really would like to retrieve the message ID once I send a message.
I can't find where I can retrieve this.
It's sent back by the server like: 250 OK id=1K4Md1-0004B5-NO
The client just returns me a boolean.
Thanks !
|
|
|
|
|
I have been tasked with researching third party object-relational mapping and RAD frameworks for .NET
Our organization is just starting a long term migration from VFP to C# / .NET and wants to kick start this process by employing a third - party ORM framework.
I have not used any third party frameworks for ORM in .NET yet and don't want to get painted into a corner at this early stage.
One of the frameworks we are reviewing is called Mere Mortals.NET by Oak Leaf Enterprises Solution Design.
I have also heard of another product called IdeaBlade Dev Force.
Anybody had experience with these products or third-party ORM frameworks in general.
Thanks
Tim Holgerson
|
|
|
|
|
Tim - as you're new to the boards, I'd like to point out that it isn't good form to post on multiple forums; plus, this is a C# forum - hence you should ask a question that is more specific to C# here.
|
|
|
|
|
Sorry about that. Point taken. Was not sure which forum would be appropriate for the question
|
|
|
|
|
I prefer to just use the .NET framework. Many of these third-party "frameworks" seem to try to do a lot more than is really necessary and if you try to step out of scope you quickly make the framework your own worst enemy.
Writing C# code to access a database is surprisingly simple and so it authoring the corresponding objects. The honest truth, as I have seen from implementations at some of the big 500 is that overall cost would have been millions less without use of a "framework" on top of the .NET framework.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I've no personal experience, but a quick google search[^] turned up lots of possibilities, many of which are open source so you can play without spending $$$
Although you're targeting C#, .NET is .NET regardless of language, so you may get a better, more informed response from the lounge[^]. Cross posting is frowned upon here so a quick post with a link to this thread may be the way to go!
Dave
|
|
|
|
|
i need to detect the edges of a picture.i need a simple algorithm to acheive this. i ll prefer this in c# language.
thanks
|
|
|
|
|
Check my image processing articles here on Code Project.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|