?
Solved

Change time part of datetime field in vb.net

Posted on 2014-02-14
2
Medium Priority
?
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

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

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

Expert Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

718 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