Solved

Change time part of datetime field in vb.net

Posted on 2014-02-14
2
364 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
Comment Utility
Once your field is loaded in a Date variable called d:

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

Expert Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

20 Experts available now in Live!

Get 1:1 Help Now