Solved

Change time part of datetime field in vb.net

Posted on 2014-02-14
2
370 Views
Last Modified: 2014-02-15
Hello Experts,

I need to change part of a date field......

If i have 2014-01-31 08:59.17 for instance, how can i change it to 2014-01-31 07:00:00.

The date field will be a variable but the time i want to change it to will always be fixed.

Thanks in advannce
0
Comment
Question by:SweetingA
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39860983
Once your field is loaded in a Date variable called d:

d = d.Date.AddHours(7)
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 39861304
YourDate = new datetime(YourDate.Year, YourDate.Month, YourDate.Day).AddHours(7)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now